gulp-uglify: gulp-uglify generates source maps but mapping is incorrect
I have this task to generate bundled & minified JavaScript file:
return gulp.src(paths)
.pipe(paths.sortByFilename ? sorter(key) : gulpUtil.noop())
.pipe(plumber(eh('Error compiling javascript (' + key + ')')))
.pipe(sourcemaps.init())
.pipe(gulpBabel())
.pipe(gulpConcat(key + '.js'))
.pipe(gulp.dest(cp.build(gomModule) + '/js'))
.pipe(gulpNgAnnotate({add: true, single_quotes: true}))
.pipe(gulpUglify())
.pipe(gulpRename({ extname: '.min.js' }))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(cp.build(gomModule) + '/js'));
Looks ok: .min.js gets mangled etc and sourcemaps are generated. But unfortunatelly debugging is not possible. Mapping is incorrect - stepping through the code / locals is broken. gulp-uglify seems to be the culprit because if I remove it from the the task, mapping works (with ngAnnotations in place as well as with babel transformation). Any idea that’s going on? User versions are:
"gulp-sourcemaps": "^2.1.1",
"gulp-ng-annotate": "~2.0.0",
"gulp-babel": "^6.1.2",
"gulp-concat": "^2.6.0",
"gulp-uglify": "^2.0.0",
"gulp-rename": "~1.2.0"
About this issue
- Original URL
- State: open
- Created 8 years ago
- Comments: 16 (3 by maintainers)
Ran into this with 3.0.0, I had to set
compress: falsein the options for source maps to still work.I think I am still having this problem, but there seem to be a lot of people complaining about sourcemaps without any solutions. The problem I am having is that the sourcemaps are generated, but if I add a console.error on a certain line the line number in the browser console is wrong. Which results in being sent to the wrong line in the file. I also checked the file itself and that actually perfectly matches the development file, so not sure why browsers are mapped to the wrong line.
I am using gulp-uglify in combination with gulp-concat and disabling gulp-uglify does solve the problem, but ofcourse that is no solution. Besides both should support sourcemaps just fine according to the documentation. I already tried all other suggested sollutions in other issues and this issue and nothing seems to help. I tested in both Firefox and Chrome and both had the same issue.
Is there any update or solution for this?