gulp-file-rev
A gulp plugin to revise files and replace references with new paths.
UsageFirst, install gulp-file-rev as a development dependency: npm install --save-dev gulp-file-rev Then, add it to your gulpfile.js : var gulp = require('gulp');var gulpIf = require('gulp-if');var fileRev = require('gulp-file-rev');gulp.task('default', function() { var revision = fileRev(); return gulp .src('**/*') // revise files .pipe(gulpIf('**/*.{jpg,png,gif}', revision)) // replace references .pipe(gulpIf('**/*.{html,css,js}', revision.replace)) .pipe(gulp.dest('dist'));}); APIfileRev(options)optionsType: Object options.hashLengthThe length of the hash. Type: Number Default: 8 options.separatorThe separator between the filename and hash. Type: String Default: . options.algorithmThe algorithm function to calculate the content hash. Type: Function Default: fileRev.md5 options.queryModeIf true , the plugin will put the hash to the query string instead of the filename. Type: Boolean Default: false options.prefixThe prefix to prepended to the file path, which is usually used to prepend the CDN host. Please notice that you should set options.cwd properly. Type: String Default: `` options.cwdCurrent working directory for prefix prepending, only has an effect if options.prefix is provided. Type: String Default: process.cwd() |
请发表评论