I'm new to using gulp and am trying to create a gulpfile for my project.
My first task is to combine all my script and link tags present in index.html and replace them with only a single tag. To achieve this purpose, I'm making use of gulp-useref as below.
gulp.task('useref', ['clean'], function () {
return gulp.src(config.paths.app.src + 'index.html')
.pipe(gulpif('*.js', uglify()))
.pipe(gulpif('*.css', cleanCSS()))
.pipe(useref())
.pipe(gulp.dest(config.paths.dist.src))
});
This thing simply concatenates and minifies all my JS and CSS files and create a single script and link tag for them. All good till here.
Now, I wish to implement hashing to the combined JS and CSS files as well. For this, I'm using gulp-rev and gulp-rev-replace plugin like below.
gulp.task('useref', ['clean'], function () {
return gulp.src(config.paths.app.src + 'index.html')
.pipe(gulpif('*.js', uglify()))
.pipe(gulpif('*.css', cleanCSS()))
.pipe(useref())
.pipe(rev())
.pipe(revReplace())
.pipe(gulp.dest(config.paths.dist.src))
});
This also works good but for one small thing. It creates the hashed filenames not only for my JS and CSS files but for my index.html file as well as below.
Is there a way by which I can avoid the renaming of index.html file while still preserving the JS and CSS hashed filenames because my server would look for the index.html file in the folder rather than index-*********.html?
Thanks.