I haven't tested all browses but I use chrome regularly.
With Grunt I had no problem with uglify and the map file produced. In Chrome, when in the developer tools, both the min.js and the original .js are loaded.
I'm trying to learn Gulp and after hours of trying I cannot get the map file to link the original .js to match the .min.js.
Here is my gulpfile.js. What am I doing wrong?
var gulp = require('gulp')
, uglify = require('gulp-uglify')
, rename = require('gulp-rename')
, sourcemaps = require('gulp-sourcemaps');
// default means this task will run whenever you type “gulp” at the command line without any parameters.
gulp.task('uglify:apps', function () {
gulp.src(['core/apps/**/*.js', '!/**/*.min.js'])
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(rename({ extname: ".min.js" }))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest('core/apps/'))
;
});
gulp.task('default', ['uglify:apps']);
gulp-uglify
as of Jan 15 2014 does not have working sourcemaps built in.
This is the current solution for getting sourcemaps to work:
npm install gulp-uglify@https://github.com/floridoo/gulp-uglify/tarball/sourcemap_fix --save-dev
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
gulp.task('ug', function(){
gulp.src('./test.js')
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('./out'));
});
gulp.task('default', ['ug']);
Example repo: https://github.com/stevelacy/gulp-test-sourcemaps