Acetate Asset Revisions
Use versioned assets with Acetate for cache-busting.
Install
npm install acetate-asset-revisions --save-dev
Usage
// in acetate.conf.jsvar assetRevisions = module{ acetate;};
The manifest
option should be the path to a JSON file that maps orginal source names to versioned assets. Most build systems have a way to accomplish this including gulp-rev, grunt-filerev and hashmark for command-line users.
You will then have access to serveral helpers to use in your templates:
{% css 'path/to/css.css'%}
{% js 'path/to/js.js'%}
{% img 'path/to/img.jpg' 'alt text'%}
<!-- will lookup css/style.css in your manifest and use the versioned URL --> {% css "css/style.css" %} <!-- will lookup js/main.js in your manifest and use the versioned URL --> {% js "js/main.js" %}
You can pass any additional HTML attributes you want as options.
{% css "css/style.css", media="print" %}
- for standard string attributes use a key/value pair{% js "js/main.js", async=true %}
- for boolean attributes passtrue
as a value
Complete Examples
YOu can look at how to integrate Acetate and asset versioing into a complete build system in these samples:
- Grunt - Coming soon
- Gulp - Coming soon
- Command-line/NPM scripts
Assumptions
This project makes several assumptions about your project structure. Your manifest file must be a simple JSON file that maps original filenames to their versioned file names.
The path to this manifest file is assumed to be relative to your Acetate build folder.
Contributing
Contributions welcome! Please read the contributing guidelines first.