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

How to rev without index.html #146

Closed gembin closed 8 years ago

gembin commented 8 years ago

How to rev without index.html ? Currently my index.html is renamed

torifat commented 8 years ago

Sorry, didn't understand your problem. Check the Usage section, it doesn't need any index.html to work.

gembin commented 8 years ago

Sorry! Here is an example shows what i did.


 gulp.task('build', function () {
  //....
  return gulp.src(path.join(conf.paths.tmp, '/serve/index.html'))
        .pipe($.useref({}, lazypipe().pipe($.sourcemaps.init, { loadMaps: true })))
        .pipe($.rev())
        // ... minify css
        // ... minify  js 
       // .. minify html
       .pipe(gulp.dest('build'))
});

And the index.html just get renamed to something like index-d3cdb828b3.html

torifat commented 8 years ago

@gembin you are not using it correctly. I've found a blog post which might help you - http://bendetat.com/cleaning-and-simplifying-the-gulp-pipeline.html

gembin commented 8 years ago

Thanks a lot, I will try it.

torifat commented 8 years ago

@gembin I just updated useref of our build today and faced the same problem. I solved it with-

.pipe(gulpIf('!*.html', rev()))

I hope it will help.

gembin commented 8 years ago

Awesome, it works !

BTW: is it possible to provide an option to use custom hash function? e.g. i want app.js renamed like app-v1.0.0.js

torifat commented 8 years ago

@gembin I don't think so. It doesn't go with the main goal of our plugin.

wembernard commented 8 years ago

Thanks @torifat for the tip.

.pipe(gulpIf('!*.html', rev()))

Might be useful for many people to add this tip in the documentation, don't you think?

Before knowing about that, I was using .pipe(rename('index.html')) at the end but that was not optimal.