I am using gulp-inject and hash-generator to build my javascript files with unique names every time so as to avoid caching issues.Before building I run gulp-clean to remove the previously generator javascript files. The problem is, now every time I run npm build files are being rebuild even when nothing has changed in the source. I would like to check if something has changed in the source file before running clean and inject. I think gulp-changed has the solution, but not sure how to make it work with the hash and cleaning. Part of my implementation looks like this.
gulp.task('clean-scripts', function () {
// return del(['./static/js/**/*.js'])
return gulp.src(['./static/js/temp/**/*.js', './static/css/**/style-*.css'], {read: false})
.pipe(clean());
});
gulp.task('index', function () {
var target = gulp.src('./templates/base.html');
// It's not necessary to read the files (will speed up things), we're only after their paths:
var sources = gulp.src(['./static/js/temp/**/*.js', './static/css/'+cssFileName], {read: false}, {relative : true});
return target.pipe(inject(sources))
.pipe(gulp.dest('./templates'));
});