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:

  1. sourceroot, value url of server want able access source maps (e.g. http://localhost:3000).

  2. 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:

  1. https://www.npmjs.com/package/gulp-uglifyjs
  2. http://lisperator.net/uglifyjs/codegen

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -