Commandline application to concatenate, minify, cache-bust and replace JS references
Want to see pretty graphs? Log in now!
npm install hashcat
|1||downloads in the last day|
|19||downloads in the last week|
|24||downloads in the last month|
|Last Published By|
|Version||0.2.6 last updated a month ago|
|Keywords||concat, concatenate, minify, minifier, compiler, uglifyjs, cache, bust, deployment, ci, hashcat|
|Dependencies||lockfile, uglify-js, clean-css, fs-extra|
It works by parsing the HTML file for special markup. It then concatenates, minifies, hashes and replaces references to those files. It is ideal for use with a build tool as part of your CI pipeline.
npm install -g hashcat
Prepare your references by surrounding them with special comment blocks.
Pass the HTML file to hashcat
After processing, the above reference should be replaced with something like this:
<link rel="stylesheet" href="ec784ace.min.css" /> <script src="d41d8cd9.app-min.js"></script>
Hashcat parses the HTML files, looks for the
#cat blocks and gathers the files up.
A hash of the resulting file's contents is then taken and the first 8 characters are prepended to the file's name.
Finally, the reference blocks in the HTML are replaced with this new file.
The concatenation and minification allow for multiple files during development but a smaller, simpler asset in production.
The hash rename provides cache busting by changing the file name on each deployment if the contents have changed.
This tool is similar to the grunt-usemin task.
In our case, using grunt as part of a CI pipeline meant having to run
npm install hundreds of times a day which was not desirable.
This standalone tool solves this specific problem by reducing the external dependencies and does not leave the build agent in a transient state.