Gathering detailed insights and metrics for gulp-rev
Gathering detailed insights and metrics for gulp-rev
Gathering detailed insights and metrics for gulp-rev
Gathering detailed insights and metrics for gulp-rev
Static asset revisioning by appending content hash to filenames: `unicorn.css` → `unicorn-d41d8cd98f.css`
npm install gulp-rev
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,541 Stars
144 Commits
217 Forks
29 Watching
1 Branches
33 Contributors
Updated on 26 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-2.3%
14,503
Compared to previous day
Last week
7.6%
75,782
Compared to previous week
Last month
1.8%
307,932
Compared to previous month
Last year
-11.1%
3,689,290
Compared to previous year
1
Static asset revisioning by appending content hash to filenames
unicorn.css
→unicorn-d41d8cd98f.css
This project is feature complete. PRs adding new features will not be accepted.
Make sure to set the files to never expire for this to have an effect.
1npm install --save-dev gulp-rev
1import gulp from 'gulp'; 2import rev from 'gulp-rev'; 3 4export default () => ( 5 gulp.src('src/*.css') 6 .pipe(rev()) 7 .pipe(gulp.dest('dist')) 8);
Type: string
Default: 'rev-manifest.json'
Manifest file path.
Type: object
Type: string
Default: process.cwd()
Override the base
of the manifest file.
Type: string
Default: process.cwd()
Override the current working directory of the manifest file.
Type: boolean
Default: false
Merge existing manifest file.
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 file paths are stored at file.revOrigPath
. This could come in handy for things like rewriting references to the assets.
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.
1import gulp from 'gulp'; 2import rev from 'gulp-rev'; 3 4export default () => ( 5 // By default, Gulp would pick `assets/css` as the base, 6 // so we need to set it explicitly: 7 gulp.src(['assets/css/*.css', 'assets/js/*.js'], {base: 'assets'}) 8 .pipe(gulp.dest('build/assets')) // Copy original assets to build dir 9 .pipe(rev()) 10 .pipe(gulp.dest('build/assets')) // Write rev'd assets to build dir 11 .pipe(rev.manifest()) 12 .pipe(gulp.dest('build/assets')) // Write manifest to build dir 13);
An asset manifest, mapping the original paths to the revisioned paths, will be written to build/assets/rev-manifest.json
:
1{ 2 "css/unicorn.css": "css/unicorn-d41d8cd98f.css", 3 "js/unicorn.js": "js/unicorn-273c2c123f.js" 4}
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()
:
1import gulp from 'gulp'; 2import rev from 'gulp-rev'; 3 4export default () => ( 5 // By default, Gulp would pick `assets/css` as the base, 6 // so we need to set it explicitly: 7 gulp.src(['assets/css/*.css', 'assets/js/*.js'], {base: 'assets'}) 8 .pipe(gulp.dest('build/assets')) 9 .pipe(rev()) 10 .pipe(gulp.dest('build/assets')) 11 .pipe(rev.manifest({ 12 base: 'build/assets', 13 merge: true // Merge with the existing manifest if one exists 14 })) 15 .pipe(gulp.dest('build/assets')) 16);
You can optionally call rev.manifest('manifest.json')
to give it a different path or filename.
gulp-concat
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:
1import gulp from 'gulp'; 2import rev from 'gulp-rev'; 3import sourcemaps from 'gulp-sourcemaps'; 4import concat from 'gulp-concat'; 5 6export default () => ( 7 gulp.src('src/*.js') 8 .pipe(sourcemaps.init()) 9 .pipe(concat({path: 'bundle.js', cwd: ''})) 10 .pipe(rev()) 11 .pipe(sourcemaps.write('.')) 12 .pipe(gulp.dest('dist')) 13);
Since the order of streams are not guaranteed, some plugins such as gulp-concat
can cause the final file's content and hash to change. To avoid generating a new hash for unchanged source files, you can:
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:
1import gulp from 'gulp'; 2import browserify from 'browserify'; 3import source from 'vinyl-source-stream'; 4import buffer from 'gulp-buffer'; 5import rev from 'gulp-rev'; 6 7export default () => ( 8 browserify('src/index.js') 9 .bundle({debug: true}) 10 .pipe(source('index.min.js')) 11 .pipe(buffer()) 12 .pipe(rev()) 13 .pipe(gulp.dest('dist')) 14);
For more info on how to integrate gulp-rev
into your app, have a look at the integration guide.
It may be useful - and necessary - to use gulp-rev
with other packages to complete the task.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 11/30 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
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 More