gulp-hash

Cachebust your assets by adding a hash to the filename
npm install --save-dev gulp-hash
Basic usage
var hash = require('gulp-hash');
gulp.src('./js/**/*.js')
.pipe(hash())
.pipe(gulp.dest('public/js'))
.pipe(hash.manifest('assets.json'))
.pipe(gulp.dest('public'));
The "manifest" is a JSON file that maps the original filenames to the renamed ones.
Streaming
The plugin has full streaming support. If you encounter any problems, please open an issue on GitHub and I'll look into it!
API
hash(options)
algorithm | 'sha1' | A hashing algorithm for crypto.createHash |
hashLength | 8 | The length of the hash to add to the file's name (slice from the start of the full hash) |
template | '<%= name %>-<%= hash %><%= ext %>' | The template used when adding the hash |
version | '' | A key to change the files' hashes without actually changing their content; appended to the contents when hashing |
hash.manifest(manifestPath, append)
manifestPath | | The desired path to the manifest file |
append | true | Whether to merge the new manifest with an existing one's contents (same filename, doesn't have to exist before first run) |