gulp-rev
Static asset revisioning by appending content hash to filenames
unicorn.css
→unicorn-d41d8cd98f.css
Make sure to set the files to never expire for this to have an effect.
🔥 Want to strengthen your core JavaScript skills and master ES6?
I would personally recommend this awesome ES6 course by Wes Bos.
Install
$ npm install --save-dev gulp-rev
Usage
var gulp = ;var rev = ; gulp;
API
rev()
rev.manifest([path], [options])
path
Type: string
Default: "rev-manifest.json"
Manifest file path.
options
base
Type: string
Default: process.cwd()
Override the base
of the manifest file.
cwd
Type: string
Default: process.cwd()
Override the cwd
(current working directory) of the manifest file.
merge
Type: boolean
Default: false
Merge existing manifest file.
transformer
Type: object
Default: JSON
An object with parse
and stringify
methods. This can be used to provide a
custom transformer instead of the default JSON
for the manifest file.
Original path
Original file paths are stored at file.revOrigPath
. This could come in handy for things like rewriting references to the assets.
Asset hash
The hash of each rev'd file is stored at file.revHash
. You can use this for customizing the file renaming, or for building different manifest formats.
Asset manifest
var gulp = ;var rev = ; gulp;
An asset manifest, mapping the original paths to the revisioned paths, will be written to build/assets/rev-manifest.json
:
By default, rev-manifest.json
will be replaced as a whole. To merge with an existing manifest, pass merge: true
and the output destination (as base
) to rev.manifest()
:
var gulp = ;var rev = ; gulp;
You can optionally call rev.manifest('manifest.json')
to give it a different path or filename.
gulp-concat
Sourcemaps and Because of the way gulp-concat
handles file paths, you may need to set cwd
and path
manually on your gulp-concat
instance to get everything to work correctly:
var gulp = ;var rev = ;var sourcemaps = ;var concat = ; gulp
Streaming
This plugin does not support streaming. If you have files from a streaming source, such as browserify, you should use gulp-buffer before gulp-rev
in your pipeline:
var gulp = ;var browserify = ;var source = ;var buffer = ;var rev = ; gulp;
Integration
For more info on how to integrate gulp-rev into your app, have a look at the integration guide.
Works with gulp-rev
- gulp-rev-replace - Rewrite occurences of filenames which have been renamed
- gulp-rev-css-url - Override URLs in CSS files with the revved ones
- gulp-rev-outdated - Old static asset revision files filter
- gulp-rev-collector - Static asset revision data collector
- rev-del - Delete old unused assets
- gulp-rev-delete-original - Delete original files after rev
- gulp-rev-loader - Use rev-manifest with webpack
- gulp-rev-format - Provide hash formatting options for static assets (prefix, suffix, last-extension)
License
MIT © Sindre Sorhus