Rewrite occurences of filenames which have been renamed by gulp-rev
Installations
npm install gulp-rev-replace
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=0.10.0
Node Version
9.4.0
NPM Version
5.6.0
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
jamesknelson
Download Statistics
Total Downloads
18,844,452
Last Day
5,191
Last Week
23,679
Last Month
113,267
Last Year
1,423,602
GitHub Statistics
388 Stars
85 Commits
62 Forks
12 Watching
1 Branches
17 Contributors
Bundle Size
32.47 kB
Minified
9.48 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.4.4
Package Id
gulp-rev-replace@0.4.4
Size
6.29 kB
NPM Version
5.6.0
Node Version
9.4.0
Publised On
03 Feb 2018
Total Downloads
Cumulative downloads
Total Downloads
18,844,452
Last day
-4.8%
5,191
Compared to previous day
Last week
-18.3%
23,679
Compared to previous week
Last month
9.8%
113,267
Compared to previous month
Last year
-12.1%
1,423,602
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
5
gulp-rev-replace
Rewrite occurrences of filenames which have been renamed by gulp-rev
Install
1$ 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.
1var gulp = require('gulp'); 2var rev = require('gulp-rev'); 3var revReplace = require('gulp-rev-replace'); 4var useref = require('gulp-useref'); 5var filter = require('gulp-filter'); 6var uglify = require('gulp-uglify'); 7var csso = require('gulp-csso'); 8 9gulp.task("index", function() { 10 var jsFilter = filter("**/*.js", { restore: true }); 11 var cssFilter = filter("**/*.css", { restore: true }); 12 var indexHtmlFilter = filter(['**/*', '!**/index.html'], { restore: true }); 13 14 return gulp.src("src/index.html") 15 .pipe(useref()) // Concatenate with gulp-useref 16 .pipe(jsFilter) 17 .pipe(uglify()) // Minify any javascript sources 18 .pipe(jsFilter.restore) 19 .pipe(cssFilter) 20 .pipe(csso()) // Minify any CSS sources 21 .pipe(cssFilter.restore) 22 .pipe(indexHtmlFilter) 23 .pipe(rev()) // Rename the concatenated files (but not index.html) 24 .pipe(indexHtmlFilter.restore) 25 .pipe(revReplace()) // Substitute in new filenames 26 .pipe(gulp.dest('public')); 27});
It is also possible to use gulp-rev-replace without gulp-useref:
1var rev = require("gulp-rev"); 2var revReplace = require("gulp-rev-replace"); 3gulp.task("revision", ["dist:css", "dist:js"], function(){ 4 return gulp.src(["dist/**/*.css", "dist/**/*.js"]) 5 .pipe(rev()) 6 .pipe(gulp.dest(opt.distFolder)) 7 .pipe(rev.manifest()) 8 .pipe(gulp.dest(opt.distFolder)) 9}) 10 11gulp.task("revreplace", ["revision"], function(){ 12 var manifest = gulp.src("./" + opt.distFolder + "/rev-manifest.json"); 13 14 return gulp.src(opt.srcFolder + "/index.html") 15 .pipe(revReplace({manifest: manifest})) 16 .pipe(gulp.dest(opt.distFolder)); 17});
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:
1{"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:
1function replaceJsIfMap(filename) { 2 if (filename.indexOf('.map') > -1) { 3 return filename.replace('js/', ''); 4 } 5 return filename; 6} 7 8return gulp.src(opt.distFolder + '**/*.js') 9 .pipe(revReplace({ 10 manifest: manifest, 11 modifyUnreved: replaceJsIfMap, 12 modifyReved: replaceJsIfMap 13 })) 14 .pipe(gulp.dest(opt.distFolder));
Contributors
- Chad Jablonski
- Denis Parchenko
- Evgeniy Vasilev
- George Song
- HÃ¥kon K. Eide
- Juan Lasheras
- Majid Burney
- Simon Ihmig
- Vincent Voyer
- Bradley Abrahams
License
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 8/20 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 18 are checked with a SAST tool
Score
3.6
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to gulp-rev-replace
gulp-rev-collector
Static asset revision data collector from manifests, with was generated from different streams and replace they's links in html template.
@types/gulp-rev-replace
TypeScript definitions for gulp-rev-replace
gulp-replace-src
Rewrite occurences of filenames which have been renamed by gulp-rev
gulp-rev-rewrite
Rewrite references to assets that have been revisioned using gulp-rev