var replace = require('gulp-replace');
function cache_version() {
return (Math.floor((Math.random() * 1000) + 1)).toString();
}
gulp.task('version', function () {
var version = cache_version();
var regex = /src(\s)?=(\s)?["'][\S]*(\.)js/g;
gulp.src('src/*.html')
.pipe(replace(regex, function (found) {
return found += '?v=' + version;
}))
.pipe(gulp.dest('build'));
});
Last active
October 18, 2015 08:45
-
-
Save skellertor/c00f1706c42747dcdc01 to your computer and use it in GitHub Desktop.
Custom gulp tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment