gulp-usemin is generating and appending css sourcemap link tag to output html, but not doing for js. How do I stop it from appending the sourcemap tag?
Gulp task:
gulp.task('build', function () {
return gulp.src('templates/**')
.pipe(usemin({
css: [sourcemaps.init({ loadMaps: true }), 'concat', cleanCss(), rev(), sourcemaps.write('./')],
js: [sourcemaps.init({ loadMaps: true }), 'concat', uglify(), rev(), sourcemaps.write('./')]
}))
.pipe(gulp.dest('public'));
});
Source HTML:
<!-- build:css css/style.min.css -->
<link href="css/main.css" rel="stylesheet" media="screen">
<link href="css/style.css" rel="stylesheet" media="screen">
<!-- endbuild -->
<!-- build:js js/script.min.js -->
<script src="js/main.js"></script>
<script src="js/script.js"></script>
<!-- endbuild -->
And this is the result output. Notice the extra sourcemap css link tag, but there is no respective sourcemap script tag for JS maps. Why is so and how do I stop inserting sourcemap tag for css??
<link rel="stylesheet" href="css/style-cd92eb4ce7.min.css.map" media="screen"/>
<link rel="stylesheet" href="css/style-cd92eb4ce7.min.css" media="screen"/>
<script src="js/script-602bf332b2.min.js"></script>
If you look at the source code for
gulp-useminyou can see why this works for JS but not for CSS.gulp-useminexplicitly makes sure to only create<script>tags for files that end in.js. There is no such check for CSS.This might be an oversight on the part of the
gulp-useminmaintainers, so you should make sure to let them know on their issue tracker.In case you have absolutely no other option and the issue is not fixed in
gulp-useminitself, here's a workaround:The above adds another processing stage
writeAndRemoveSourceMapsto thecsspipeline, right aftersourcemaps.write()has pushed the.mapfile to the stream. This stage manually writes the.mapfile to the destination directory and then removes it from the stream again, so that it can't reachgulp-useminand no<link>tag for it is created.