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

Question: Adding Version instead of Content File Hash at the end? #129

Closed open-cipher closed 9 years ago

open-cipher commented 9 years ago

As a feature, would it not be cool to have an option to use package.json version tag value to be suffixed at the end of file name rather than using content hash?

Something like this:

mode: 'version'
var gulp = require('gulp');
var rev = require('gulp-rev');

gulp.task('default', function () {
    return gulp.src('src/*.css')
        .pipe(rev({mode: 'version'}))
        .pipe(gulp.dest('dist'));
});
Output

abc-1.2.0.css

Default or None
var gulp = require('gulp');
var rev = require('gulp-rev');

gulp.task('default', function () {
    return gulp.src('src/*.css')
        .pipe(rev() /* or rev({mode: 'default'})*/)
        .pipe(gulp.dest('dist'));
});
Output

abc-bxc23dd564c.css

sindresorhus commented 9 years ago

Sounds like a really bad idea. That would invalidate the cache for all files even though only some changed.

open-cipher commented 9 years ago

Agreed, but for cases where the plugin is being used to generate semver builds, for e.g. jQuery-1.2.3.js etc ... this can come in handy. Also, It can only be an option.

kevva commented 9 years ago

I don't think this plugin should be used to generate semver builds though.

bobthecow commented 9 years ago

gulp-rename is a perfect plugin for the job :)

open-cipher commented 9 years ago

@bobthecow : Thanks, how did I miss that :( !!

bobthecow commented 9 years ago

@akshayKrSingh Heh. No worries :)