gulp-rev-replace
gulp-rev-replace copied to clipboard
fail to work with [email protected]
rev-replace will replace original
<script> x.js</script>
with
<script>x.somehash.map</script>
Here is my gulp task:
.pipe(useref())
.pipe(jsFilter)
.pipe(sourcemaps.init())
.pipe(ngAnnotate())
.pipe(uglify({preserveComments: uglifySaveLicense})).on('error', conf.errorHandler('Uglify'))
.pipe(rev())
.pipe(sourcemaps.write('maps'))
.pipe(jsFilter.restore)
.pipe(revReplace())
Oh I'm so glad I'm not the only one.
I worked around this with a filter that filtered out map files:
const removeMapFiles = filter(['**/*', '!maps/**')], {restore: true});
// gulp stuff here...
.pipe(removeMapFiles) // remove map files from the stream because we don't want them written to the markup
.pipe(revReplace())
.pipe(removeMapFiles.restore)
Here's a tiny reproducible project: https://github.com/akatakritos/gulp-rev-replace-repro
I'll look into a fix this afternoon as well.
@akatakritos - thanks, that solved my issue. But you have some small issues in example
const removeMapFiles = filter(['**/*', '!maps/**'], {restore: true});
// gulp stuff here...
.pipe(removeMapFiles) // remove map files from the stream because we don't want them written to the markup
.pipe(revReplace())
.pipe(removeMapFiles.restore())
``