gulp-rev-versionhash
Static asset revisioning by appending content hash to filenames
unicorn.css
→unicorn.css?v=d41d8cd98f
Install
$ npm install --save-dev gulp-rev-versionhash
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