gulp-uglify: Uglify not working with gulp-sourcemaps
When I try and uglify my code without concatenating it and then generate source maps I get an error message like:
gulp-sourcemap-write: source file not found:C:\Rob\Dropbox\Repos\gulpTest\?
my gulp task looks like this
gulp.task('js', function () {
return gulp.src('app.js')
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('build'));
});
I’m using the following versions of npm modules
"dependencies": {
"gulp": "3.8.8",
"gulp-uglify": "1.0.1",
"gulp-sourcemaps": "1.1.5"
}
There is a zipped up version of the project here https://dl.dropboxusercontent.com/u/20066539/Forum Links/Other/gulpTest.zip
This issue is related to https://github.com/floridoo/gulp-sourcemaps/issues/34
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 48 (7 by maintainers)
Commits related to this issue
- Set mangled.map.sources from file.sourceMap.sources. This is to temporarily work around an integration issue with UglifyJS2 that results in broken source maps. See #56. — committed to jmm/gulp-uglify by jmm 10 years ago
- Fix sources path in source maps (fixes #56) — committed to floridoo/gulp-uglify by floridoo 10 years ago
- Merge pull request #74 from floridoo/sourcemap_fix Fix sources path in source maps (fixes #56) — committed to terinjokes/gulp-uglify by terinjokes 9 years ago
I’m having the same problem. It seems that
concatsomehow fixes it, so if you use……everything is working fine. However, without the line that applies
concatyou get an invalid source map ("sources":["?"],"sourcesContent":[null])I have several files I do not want to concatenate. As a workaround I could just put each single file in a separate
gulp.src()statement, then apply the pipe operations (includingconcatfor that single file, which normally should be a noop, but isn’t here as it fixes the bug) and at the end merge them together, but that would not be very pretty. This should work withoutconcatand with multiple input files.Any ideas?