 <p>So this is how sourcemaps work in Gulp: Each element you select via <code>gulp.src</code> gets transferred into a virtual file object, consisting of the contents in a Buffer, as well as the original file name. Those are piped through your stream, where the contents get transformed.</p> <p>If you add sourcemaps, you add one more property to those virtual file objects, namely the sourcemap. With each transformation, the sourcemap gets also transformed. So, if you initialize the sourcemaps after concat and before uglify, the sourcemaps stores the transformations from that particular step. The sourcemap "thinks" that the original files are the output from concat, and the only transformation step that took place is the uglify step. So when you open them in your browser, nothing will match.</p> <p>It's better that you place sourcemaps directly after globbing, and save them directly before saving your results. <strong>Gulp sourcemaps will interpolate between transformations, so that you keep track of every change that happened</strong>. The original source files will be the ones you selected, and the sourcemap will track back to those origins.</p> <p>This is your stream:</p> <pre><code> return gulp.src(sourceFiles) .pipe(sourcemaps.init()) .pipe(plumber()) .pipe(concat(filenameRoot + '.js')) .pipe(gulp.dest(destinationFolder)) // save .js .pipe(uglify({ preserveComments: 'license' })) .pipe(rename({ extname: '.min.js' })) .pipe(sourcemaps.write('maps')) .pipe(gulp.dest(destinationFolder)) // save .min.js </code></pre> <p><code>sourcemaps.write</code> does not actually write sourcemaps, it just tells Gulp to materialize them into a physical file when you call <code>gulp.dest</code>. </p> <p>The very same sourcemap plugin will be included in Gulp 4 natively: <a href="http://fettblog.eu/gulp-4-sourcemaps/">http://fettblog.eu/gulp-4-sourcemaps/</a> -- If you want to have more details on how sourcemaps work internally with Gulp, they are in Chapter 6 of my Gulp book: <a href="http://www.manning.com/baumgartner">http://www.manning.com/baumgartner</a></p>