question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

can not find the source map file when use UglifyJsPlugin

See original GitHub issue
gulp.task('test', function() {
    gulp.src('frontends/scripts/index.js')
        .pipe(webpack({
            plugins: [
                new webpack.webpack.optimize.UglifyJsPlugin({ minimize: true, sourceMap: true })
            ]
        }))
        .pipe(rename("index.min.js"))
        .pipe(gulp.dest('frontends/build/scripts/'));
});

The index.min.js is created and minified properly, but I can not find any source map file. And there is no //# sourceMappingURL=index.min.map at the end of index.min.js file. Considering UglifyJsPlugin does have sourceMap option, is this a bug of webpack-stream?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

83reactions
bennycodecommented, Aug 30, 2016

Using webpack 2.1.0-beta.21, I needed to set sourceMap: true on webpack.optimize.UglifyJsPlugin AND devtool: 'source-map'.

So in the end my configuration looked like this:

webpack.config.js

var webpack = require('webpack');

module.exports = {
  devtool: 'source-map',
  entry: {
    filename: './build/proteus.js'
  },
  output: {
    filename: 'proteus-bundle.js',
    library: 'proteus',
    libraryTarget: 'amd',
    path: './dist'
  },
  node: {
    fs: 'empty',
    crypto: 'empty'
  },
  externals: {
    'libsodium-native': 'libsodium_native'
  },
  plugins: [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress: {warnings: false},
      output: {comments: false},
      sourceMap: true
    })
  ]
};
4reactions
kisenkacommented, Dec 9, 2016

It doesn’t work with devtool: 'cheap-module-source-map'

Read more comments on GitHub >

github_iconTop Results From Across the Web

Source Maps Not Generated by WebPack - Stack Overflow
js file, I should get source map files that map to original code. I'm using the following config file and I'm not getting...
Read more >
uglify-js - npm
UglifyJS can generate a source map file, which is highly useful for debugging your compressed JavaScript. To get a source map, pass --source-map...
Read more >
Source Maps - SurviveJS
If you build the project now ( npm run build ), you should see source maps in the project output at the dist...
Read more >
Source Map - node_modules - Gitlab
and an object is returned with the following properties: source : The original source file, or null if this information is not available....
Read more >
Debugging JavaScript with Source Maps - Rollbar
If you already know how to generate a source map or just want to use the generated file, you can skip down to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found