A Brunch plugin that appends a unique SHA digest to asset filenames.
npm install digest-brunchI am no longer maintaining digest-brunch. I switched to Webpack for my front end
applications. Contact me (@mutewinter) if you'd like to take over support for
digest-brunch.
A [Brunch][] plugin that appends a unique SHA digest to asset filenames. Allows
for [far-future caching][am] of assets.
_Note: digest-brunch is not compatible with [gzip-brunch][]._
Usage
-----
npm install --save digest-brunch
Identify assets that you want to be digested with DIGEST(filename.ext), or a custom pattern of your choosing.
``html`
Run brunch build --production and you'll see something like the following:
_Note: digest-brunch can not be run in watch mode. It's only intended for
production builds, run once._
`html`
The asset files are also renamed, inside the public folder, to match the names
above.
Options
-------
_Optional_ You can override digest-brunch's default options by updating your
config.coffee with overrides.
These are the default settings:
`coffeescript`
exports.config =
# ...
plugins:
digest:
# A RegExp where the first subgroup matches the filename to be replaced
pattern: /DIGEST\(\/?([^\)]*)\)/g
# After replacing the filename, should we discard the non-filename parts of the pattern?
discardNonFilenamePatternParts: yes
# RegExp that matches files that contain DIGEST references.
referenceFiles: /\.html$/
# How many digits of the SHA1 to append to digested files.
precision: 8
# Force digest-brunch to run in all environments when true.
alwaysRun: false
# Specify an array of environments to run in.
environments: ['production']
# Prepend an asset host URL to the file paths in the reference files. Use an object e.g. {production: 'http://production-asset-host.co'}
prependHost: null
# Output filename for a JSON manifest of reference file paths and their digest.
manifest: ''
# An array of infixes for alternate versions of files. This is useful when e.g. using retina.js (http://imulus.github.io/retinajs/) (@2x) for high density images.
infixes: []
Contributing
------------
1. Add some code
1. Add some tests
1. Run npm test`
1. Send a pull request
License
-------
MIT
[Brunch]: http://brunch.io
[am]: http://blog.alexmaccaw.com/time-to-first-tweet
[gzip-brunch]: https://github.com/banyan/gzip-brunch
[npm]: https://npmjs.org/package/digest-brunch
[npm-badge]: http://img.shields.io/npm/v/digest-brunch.svg?style=flat
[travis]: https://travis-ci.org/mutewinter/digest-brunch
[travis-badge]: https://img.shields.io/travis/mutewinter/digest-brunch.svg?style=flat
[gemnasium]: https://gemnasium.com/mutewinter/digest-brunch
[gemnasium-badge]: https://img.shields.io/gemnasium/mutewinter/digest-brunch.svg?style=flat