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

Option to override original files #149

Open Francisc opened 8 years ago

Francisc commented 8 years ago

Hi,

Is there a way (or future plans) to provide an option to gulp-rev asking it to rename / replace the original files instead of preserving them and creating new ones?

Thanks.

zckrs commented 8 years ago

Strange feature asked. But keep in your mind one Gulp plugin = one feature

After gulp-rev you can use gulp-rename and gulp.dest to move your files

bobthecow commented 8 years ago

Check out gulp-rev-delete-original.

Francisc commented 8 years ago

It's more like an option than a feature. This plugin takes style.css and creates style.ab123.css. Why not take an {override:true} option to replace the revisioned file? I can't think of any use case where one would like to keep both.

I know about gulp-rev-delete-original, but it's easier to pass a flag than to add another dependency.

bobthecow commented 8 years ago

I can't think of any use case where one would like to keep both.

I can't think of any use case where the first should be written to disk to begin with :)

Francisc commented 8 years ago

Ha, well I like to keep the rev tasks separate from the CSS, JS etc tasks so that it's like a component I can remove or replace easily.

So it would looke like: 'build-js', 'revision-js' Build writes to dist, revision reads from dist and writes again.

There's also gulp.watch and livereloading that don't play well with revisioning assets because they also update HTML files and that triggers a full reload instead of a local one - like for CSS files.

zhouzi commented 7 years ago

That sounds like an interesting idea. Just to be sure, @Francisc you are suggesting that old files should be deleted when new ones are created?

For examples, you have a css file that is revised into styles-123.css. You make some changes and the css file is revised again, into styles-456.css.

In this situation, you would like to have an option to tell gulp-rev to delete styles-123.css, right?

It makes sense. We'd have to think about it and make sure it's not colliding with other aspects though.

ZhangShuaiGe commented 4 years ago

gulp-rev 是如何知道我修改了哪些文件的?原理是什么?看完源码,没看懂。。。 每一次构建 gulp-rev是如何知道 我上一次构建状态的,我构建的时候,已经加入了很多代码