2

I am trying to use gulp-sourcemaps to generate source map.

Example code:

gulp.task('compressjs', function() {
    gulp.src(['public/js/**/*.js','!public/js/**/*.min.js'])
    .pipe(sourcemaps.init())
    .pipe(uglify())
    .pipe(rename({
        extname: '.min.js'
    }))
    .pipe(gulp.dest('public/js'))
    .pipe(sourcemaps.write('/'))
    .pipe(gulp.dest('public/js'));
});

The output of the path is //# sourceMappingURL=/script.min.js.map, which is the wrong path. The correct one should be //# sourceMappingURL=script.min.js.map. How can I remove that extra / in the URL?

user1995781
  • 19,085
  • 45
  • 135
  • 236

1 Answers1

4

Use sourcemaps.write('.') to write the map file to same directory as js file.

Also the first .pipe(gulp.dest('public/js')) is not necessary.

Heikki
  • 15,329
  • 2
  • 54
  • 49