sindresorhus / gulp-rev

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

Disable hash adding to certain file #111

Closed rapidfixer closed 9 years ago

rapidfixer commented 9 years ago

I've got certain file with filename that should be frozen after gulp-rev. What should i do to tell rev not to add hash to this file? Thanks.

sindresorhus commented 9 years ago

You can filter it out with gulp-filter.

borisceranic commented 9 years ago

@rapidfixer, you should use other means of removing the file from gulp-rev's input, for example using gulp-filter, like this:

var rev = require('gulp-rev');
var filter = require('gulp-filter');

var skipFilesFilter = filter(function(file){
    return /skipthisfile\.css$/
        .test(file.path);
});

gulp.src('static-files/**/*')
    // ...transformations...
    .pipe(skipFilesFilter)
    .pipe(rev())
    .pipe(skipFilesFilter.restore())
    // ...some more transformations...
    .pipe(gulp.dest('output-dir'))
    // ...generate and save rev-manifest.json...

Of course, you don't have to invoke same filter when calling gulp-rev-manifest, since the removed file is not kept in the list of revisioned files.