1.0.0 • Published 8 years ago

acetate-asset-revisions v1.0.0

Weekly downloads
6
License
ISC
Repository
github
Last release
8 years ago

Acetate Asset Revisions

npm travis

Use versioned assets with Acetate for cache-busting.

Install

npm install acetate-asset-revisions --save-dev

Usage

// in acetate.conf.js
var assetRevisions = require('acetate-asset-revisions')

module.exports = function(acetate){
  acetate.use(assetRevisions({
    manifest: 'build/assets.json'
  }));
};

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'%}
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">

    <!-- will lookup css/style.css in your manifest and use the versioned URL -->
    {% css "css/style.css" %}
  </head>
  <body>
    <!-- will lookup js/main.js in your manifest and use the versioned URL -->
    {% js "js/main.js" %}
  </body>
</html>

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 pass true as a value

Complete Examples

YOu can look at how to integrate Acetate and asset versioing into a complete build system in these samples:

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.

{
  "css/style.css": "css/style-098f6bcd.css",
  "js/main.js": "js/main-273c2cin.js"
}

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.

License

ISC

1.0.0

8 years ago

0.1.0

9 years ago