sindresorhus / gulp-rev

Static asset revisioning by appending content hash to filenames: `unicorn.css` → `unicorn-d41d8cd98f.css`
MIT License
1.54k stars 218 forks source link

Add time stamp to rev hash ... #127

Closed michalskyPL closed 8 years ago

michalskyPL commented 8 years ago

Hi, my gulp-rev add revs to zipped app/page template.

my workflow app -> zip -> revision, and i want to add a timestamp to rev hash like this : date_hash_filename.ext

my gulpfile.js

var rev = require('gulp-rev'); var date = new Date(dateString); gulp.task('rev', function () { return gulp.src('app/*.zip') .pipe(rev()) .pipe(gulp.dest('deploy/')); });

Should i add new Date().toString()) to rev() or edit the index.js in rev-hash or rev-path ?

kevva commented 8 years ago

https://github.com/sindresorhus/gulp-rev#asset-hash. Try the following:

var modifyFilename = require('modify-filename');
var through = require('through2');

.pipe(rev())
.pipe(through.obj(function (file, enc, cb) {
    file.path = modifyFilename(file.revOrigPath, function (name, ext) {
        return [new Date().toString(), file.revHash, name + ext].join('_');
    });

    cb(null, file);
})
.pipe(gulp.dest('deploy/'));