Max Bündchen Max Bündchen - 2 months ago 26
jQuery Question

Remove Source Mapping with Gulp

I'm using Gulp and Bower to get JQuery into my project. However the jquery.min.cs file has a SourceMappingURL at the end of the precompiled file and I would like to remove this.

Currently my Gulp just copy the original file to the destination like that:

gulp.task('jquery', function () {
gulp.src(paths.jquerySrc)
.pipe(gulp.dest(paths.jqueryDest));
});


I found a lot of ways to add source mappings but none to remove. I would like to not recompile all the jquery just for that.

Answer

You could try this:

const paths = {
    jquerySrc: './path/to/src/jquery.css',
    jqueryDest: './path/to/dest/'
};

gulp.task('jquery', function () {
    gulp.src(paths.jquerySrc)
        .pipe(sourcemaps.init({loadMaps: true}))
        .pipe(sourcemaps.write('/dev/null', {addComment: false}))
        .pipe(gulp.dest(paths.jqueryDest));
});

You could also try the strip-source-map-loader package. Never used either, but in theory both should work, maybe.