I'm trying to generate sourcemap files for uglified javascript with gulp. My task looks as follows:
gulp.task('scripts', ['clean'], function() {
return gulp.src([ 'src/app/**/*.js' ])
.pipe(sourcemaps.init())
.pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dest/app'));
});
The output map generated by gulp-sourcemaps
contains an empty names
array, which prevents the browser to unmangle the function arguments back to its original names.
It seems to me that gulp-sourcemaps
isn't merging the chained map files correctly? The gulp-concat
does not output a names
property (it doesn't needs to: it's simply concating) but gulp-uglify
does:
gulp.task('scripts', ['clean'], function() {
return gulp.src([ 'src/app/**/*.js' ])
.pipe(sourcemaps.init())
// .pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dest/app'));
});
The above does generates correct map files with the names
property set.
Am I doing something wrong or does someone has a workaround for this?