I'm wondering how to get gulp-rev-replace to replace file references with the same hash across HTML files in subfolders. Considering the following file structure
- index.html
- subfolder
- index.html
- scripts
- main.js
- styles
- main.scss
And the following html statements:
index.html:
<!-- build:css styles/main.css -->
<link rel="stylesheet" href="/bower_components/normalize-css/normalize.css">
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
subfolder/index.html:
<!-- build:css ../styles/main.css -->
<link rel="stylesheet" href="/bower_components/normalize-css/normalize.css">
<link rel="stylesheet" href="../styles/main.css">
<!-- endbuild -->
And the following in my Gulpfile
gulp.task('html', ['styles'], () => {
const assets = $.useref.assets({searchPath: ['.tmp', 'app', '.']});
return gulp.src('app/**/*.html')
.pipe(assets)
.pipe($.if('*.js', $.uglify()))
.pipe($.if('*.css', $.minifyCss({compatibility: '*'})))
.pipe($.rev())
.pipe(assets.restore())
.pipe($.useref())
.pipe($.revReplace())
.pipe($.if('*.html', $.minifyHtml({conditionals: true, loose: true})))
.pipe(gulp.dest('dist'));
});
The style link block in index.html
will get replacced with the correct minified and hashed stylesheet reference. The same block in subfolder/index.html
will instead get an entirely different hashed stylesheet reference. It does, however, get the path of the stylesheet correct.
Am I setting up my Gulpfile incorrectly?