gulp-rev-replace
Rewrite occurrences of filenames which have been renamed by gulp-rev
TheDancingCode/gulp-rev-rewrite.
Note: this package is no longer maintained. Development continues inInstall
$ npm install --save-dev gulp-rev-replace
Usage
Pipe through a stream which has both the files you want to be updated, as well as the files which have been renamed.
For example, we can use gulp-useref to concatenate assets in an index.html, and then use gulp-rev and gulp-rev-replace to cache-bust them.
var gulp = ;var rev = ;var revReplace = ;var useref = ;var filter = ;var uglify = ;var csso = ; gulp;
It is also possible to use gulp-rev-replace without gulp-useref:
var rev = ;var revReplace = ;gulp gulp;
API
revReplace(options)
options.canonicalUris
Type: boolean
Default: true
Use canonical Uris when replacing filePaths, i.e. when working with filepaths
with non forward slash (/
) path separators we replace them with forward slash.
options.replaceInExtensions
Type: Array
Default: ['.js', '.css', '.html', '.hbs']
Only substitute in new filenames in files of these types.
options.prefix
Type: string
Default: ``
Add the prefix string to each replacement.
options.manifest
Type: Stream
(e.g., gulp.src()
)
Read JSON manifests written out by rev
. Allows replacing filenames that were
rev
ed prior to the current task.
options.modifyUnreved, options.modifyReved
Type: Function
Modify the name of the unreved/reved files before using them. The filename is passed to the function as the first argument.
For example, if in your manifest you have:
"js/app.js.map": "js/app-98adc164.js.map"
If you wanted to get rid of the js/
path just for .map
files (because they
are sourcemaps and the references to them are relative, not absolute) you could
do the following:
{ if filename > -1 return filename; return filename;} return gulp ;
Contributors
- Chad Jablonski
- Denis Parchenko
- Evgeniy Vasilev
- George Song
- Håkon K. Eide
- Juan Lasheras
- Majid Burney
- Simon Ihmig
- Vincent Voyer
- Bradley Abrahams