Sourcemap source files are empty using gulp-uglifyjs -
looks source map files blank.
my code follows.
gulp.src(sources) .pipe(uglifyjs('app.min.js', { outsourcemap: true })) .pipe(gulp.dest('public/js')) .pipe(notify({message: 'scripts task complete'}));
in browser image looks
notice how source files blank. not sure doing wrong here. can please help.
i add source files using module pattern i.e.
(function () { "use strict"; //my code in here }())
per gulp-uglifyjs documentation:
outsourcemap
(default false) give string name of source map. set true , [...]
note: if source map point relative paths instead of absolute paths (which if hosted on server), set basepath option base of content served.
[...]
sourceroot
sets root location source files should found
with above in mind, need add 2 options gulp-uglifyjs call in gulpfile:
sourceroot, value url of server want able access source maps (e.g. http://localhost:3000).
basepath, should map gulpfile's containing directory relative path of webserver root. example, if webserver serving it's content directory 'src' within gulpfile's containing directory want use value of "/src".
the following example assumes you're running webserver @ http://localhost:3000 , webserver root in directory "src" within directory containing gulpfile:
gulp.src(sources) .pipe(uglifyjs('app.min.js', { outsourcemap: true, basepath: "/src", sourceroot: "http://localhost:3000" })) .pipe(gulp.dest('public/js')) .pipe(notify({message: 'scripts task complete'}));
helpful references:
Comments
Post a Comment