jamesknelson / gulp-rev-replace

Rewrite occurences of filenames which have been renamed by gulp-rev
MIT License
389 stars 62 forks source link

Using `rev-replace` on the same stream as `rev` #51

Open Francisc opened 8 years ago

Francisc commented 8 years ago

Hi,

Is it possible to use rev-replace on the same stream as rev without useref?

Doing this fails:

gulp.src(ASSETS_GLOB)
.pipe(rev())
.pipe(revReplace())
.pipe(gulp.dest(DIST_FOLDER));

Because index.html isn't in ASSETS_GLOB.

Adding it to ASSETS_GLOB will make rev-replace revision the HTML file as well, so also bad.

chaucerbao commented 7 years ago

I ended up achieving this with gulp-filter.

// Filter out HTML files, only assets are passed through
const assetFilter = filter(['**', '!**/*.html'], { restore: true });

gulp.src('**')             // Grab everything
.pipe(assetFilter)         // Filter out HTML files
.pipe(rev())               // gulp-rev
.pipe(assetFilter.restore) // Undo the filter, so we have everything again
.pipe(revReplace())        // Replace filenames
.pipe(gulp.dest(DIST_FOLDER));