Uglify Minify and create a source map using Gulp

Can someone explain how to guess and then concat and finally create a source map using gulp? I can not make it work. I don’t see anything in the API about this, but it seems to me that it should be supported. The point is to generate the source map and use the source files when setting breakpoints. I tried putting concat in the following code first, but when I do this, breakpoints do not work in the Chrome browser.

I use concat = require('gulp-concat'), and uglify = require('gulp-uglify') .

 gulp.src(['src/app.js', 'src/**/*.js']) .pipe(sourcemaps.init()) .pipe(uglify({ compress: { negate_iife: false } })) .pipe(concat("app.concat.js")) .pipe(rename('app.min.js')) .pipe(sourcemaps.write('./')) .pipe(gulp.dest('public/js')); 
+7
gulp gulp-uglify gulp-sourcemaps gulp-concat
source share
1 answer

Moving concat to uglify seems to make it work.

 gulp.src(['src/app.js', 'src/**/*.js']) .pipe(sourcemaps.init()) .pipe(concat('app.concat.js')) .pipe(uglify({ compress: { negate_iife: false } })) .pipe(rename('app.min.js')) .pipe(sourcemaps.write('./')) .pipe(gulp.dest('public/js')); 
+7
source share

All Articles