7

Can someone explain how to uglify, then concat and finally generate a source map using gulp? I cannot seem to get it working. I am not seeing anything in the API's about this but seems to me that it should be supported. The point is to generate the source map and have the source files be used when setting breakpoints. I have tried putting the concat first in the following code but when I do that the breakpoints do not work in chrome browser.

I am using
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'));
Subtubes
  • 15,851
  • 22
  • 70
  • 105

1 Answers1

7

Moving concat before 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'));
Heikki
  • 15,329
  • 2
  • 54
  • 49
  • 2
    OK that generates a source map but the breakpoints in the source files do not work on chrome. Can you confirm it works on chrome for you? – Subtubes Nov 12 '14 at 16:38
  • 1
    There's similar questions about breakpoints [here](http://stackoverflow.com/questions/26212796/cant-set-breakpoint-in-source-mapped-file-example-with-jquery) and [here](http://stackoverflow.com/questions/20013786/my-source-mapped-breakpoints-arent-working-correctly-in-google-chrome) – Heikki Nov 12 '14 at 17:10
  • Hi, was this issue solved? I had same issue with ...pipe(concat({includeContent: true}).pipe(uglify()) ... - self contained sourcemaps issue, but i believe it is same issue. A working solution is very valuable! – arty Dec 21 '15 at 13:40