Static asset revision replace their links.
$ npm install --save-dev sog-gulp-rev-collector
We can use gulp-rev to cache-bust several assets and generate manifest files for them. Then using sog-gulp-rev-collector we can collect data from several manifest files and replace links to assets in html templates.
var gulp = require('gulp');
var rev = require('gulp-rev');
gulp.task('css', function () {
return gulp.src('src/css/*.css')
.pipe(rev())
.pipe(gulp.dest('dist/css'))
.pipe( rev.manifest() )
.pipe( gulp.dest( 'rev/css' ) );
});
gulp.task('scripts', function () {
return gulp.src('src/js/*.js')
.pipe(rev())
.pipe(gulp.dest('dist/js'))
.pipe( rev.manifest() )
.pipe( gulp.dest( 'rev/js' ) );
});
...
var revCollector = require('sog-gulp-rev-collector');
var minifyHTML = require('gulp-minify-html');
gulp.task('rev', function () {
return gulp.src(['templates/**/*.html'])
.pipe( revCollector(['rev/**/*.json']) )
.pipe( minifyHTML({
empty:true,
spare:true
}) )
.pipe( gulp.dest('dist') );
});