Support for inline sourcemaps
jpzwarte opened this issue · comments
.pipe($.sourcemaps.init())
.pipe($.concat('.app.js'))
.pipe($.ngAnnotate())
.pipe($.uglify())
.pipe($.sourcemaps.write())
The above fails because gulp-ng-annotate does not work with gulp-sourcemaps. See https://github.com/floridoo/gulp-sourcemaps#plugin-developers-only-how-to-add-source-map-support-to-plugins for info on how to add this.
Unfortunately ng-annotate
does not support source maps generation. You could create issue in ng-annotate's bugtracker.
As a workaround you could create source map after ngAnnotate
was applied to the source code. You will lack some info about original code but it'll be still quite readable.
Yeah, that's what i've already done. I'll create an issue with ng-annotate.
So ng-annotate now supports the source maps. I'm planning to implement this feature soon.
I published gulp-ng-annotate
0.3.0 with source maps support to npm. Test it please.
Does this support sourcemaps created using gulp/grunt where we concat, ngannotate, and uglify and add sourcemaps? I'm seeing the line numbers being off in chrome.
return gulp
.src(source)
.pipe(plug.sourcemaps.init())
.pipe(plug.concat('all.min.js'))
.pipe(plug.ngAnnotate({
add: true
}))
.pipe(plug.uglify({mangle: true}))
.pipe(plug.sourcemaps.write('./'))
.pipe(gulp.dest(pkg.paths.stage));
@johnpapa, it seems like UglifyJS2
has some problems with --in-source-map
option. I have the very same issue with just:
...
.pipe(sourcemaps.init())
.pipe(concat('all.min.js'))
.pipe(uglify({mangle: false}))
.pipe(sourcemaps.write('.'))
...
See also: terinjokes/gulp-uglify#43
And yes, gulp-sourcemaps
does support source maps chaining so gulp-ng-annotate
should work fine in this circumstances.
Thanks @Kagami for getting this implemented so quickly! I was planning on making a PR but you got to it too fast :)