A Grunt.js task that compiles CSS and JS files with respect of file modification date. For JS, it uses built-in UglifyJS minifier, for CSS — Yandex’s CSSO with automatic @import
inlining and url()
rewriting.
Unlike basic minifiers, this task generates a hidden catalog file (.build-catalog.json
) that stores state, last compilation date and checksum of minified files. Every time you call frontend-*
task, it will look into this catalog and check if the state of files being minified was changed. If not, the file will not be re-minified which saves CPU time and modification date. This date (or checksum hash) can be used to modify URLs to minified files for effective caching.
Usage
This plugin provides frontend-js
, frontend-css
and frontend-index
multi-tasks. Global config can be defined in frontend
key. All tasks are file-based. Here’s example Gruntfile.js
:
module { grunt;};
This task can be used together with docpad-plugin-frontend to automatically generate cache-effective URLs to assets for DocPad-generated web-site.