webpack: SourceMap is missing when UglifyJSPlugin is enabled
I’m submitting a bug report
Webpack version: 2.1.0-beta.4
Please tell us about your environment: OSX 10.x
Current behavior:
Source map is not generated when new webpack.optimize.UglifyJsPlugin()
is used.
If I remove UglifyJSPlugin or use webpack version 1.13, it does produce source map.
Expected/desired behavior: Source map should be generated.
- My config
const path = require('path');
const webpack = require('webpack');
const WebpackNotifierPlugin = require('webpack-notifier');
const styleLintPlugin = require('stylelint-webpack-plugin');
const env = process.env.NODE_ENV;
module.exports = {
devtool: 'source-map',
entry: './src',
output: {
path: path.join(__dirname, 'dist'),
filename: 'app.js',
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
],
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel' },
{ test: /\.js$/, exclude: /node_modules/, loader: 'eslint' },
{ test: /\.css$/, exclude: /node_modules/, loader: 'style!css?modules&importLoaders=1&localIdentName=[local]_[hash:base64:5]' },
],
},
};
- Language: [ES6/7]
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 5
- Comments: 15 (1 by maintainers)
Commits related to this issue
- 4.0.2-beta Testing the following configuration additions: - Add `devtool`, `uglifyJsPlugin`, and `definePlugin` environment options - [Autoset `uglifyJsPlugin.sourceMap` to `true`](https://github.co... — committed to vigetlabs/blendid by deleted user 7 years ago
- 4.0.2-beta Testing the following configuration additions: - Add `devtool`, `uglifyJsPlugin`, and `definePlugin` environment options - [Autoset `uglifyJsPlugin.sourceMap` to `true`](https://github.co... — committed to vigetlabs/blendid by deleted user 7 years ago
- 4.0.2-beta Testing the following configuration additions: - Add `devtool`, `uglifyJsPlugin`, and `definePlugin` environment options - [Autoset `uglifyJsPlugin.sourceMap` to `true`](https://github.co... — committed to vigetlabs/blendid by deleted user 7 years ago
- 4.1.0 - Add production sourcemaps (#433) - Add `devtool`, `uglifyJsPlugin`, and `definePlugin` environment options - [Autoset `uglifyJsPlugin.sourceMap` to `true`](https://github.com/webpack/webpack... — committed to vigetlabs/blendid by deleted user 7 years ago
- Enable source map generation in UglifyJsPlugin Looks like it was disabled at some point and depending on the version of webpack it's enabled by default or not: https://github.com/webpack/webpack/issu... — committed to cloudflare/unsee by prymitive 7 years ago
- Enable source map generation in UglifyJsPlugin Looks like it was disabled at some point and depending on the version of webpack it's enabled by default or not: https://github.com/webpack/webpack/issu... — committed to cloudflare/unsee by prymitive 7 years ago
- Add sourcemap config to uglify plugin No sourcemaps have been generated in `dist` since `0.14.3` https://github.com/webpack/webpack/issues/2704#issuecomment-228860162 — committed to cookpete/react-player by cookpete 7 years ago
- Improve production sourcemap support In UglifyJS sourceMap need to be enabled explicitly. Usage: webextension-toolbox build chrome --devtool=source-map https://github.com/webpack/webpack/issues/27... — committed to webextension-toolbox/webextension-toolbox by HaNdTriX 6 years ago
- Improve production sourcemap support In UglifyJS source-maps need to be enabled explicitly. Example: webextension-toolbox build chrome --devtool=source-map https://github.com/webpack/webpack/issues... — committed to webextension-toolbox/webextension-toolbox by HaNdTriX 6 years ago
- Fix source map generation with prod build It was stripped by the uglify plugin, see https://github.com/webpack/webpack/issues/2704 — committed to Xcraft-Inc/goblin-webpack by Skywalker13 7 years ago
- Add sourcemap config to uglify plugin No sourcemaps have been generated in `dist` since `0.14.3` https://github.com/webpack/webpack/issues/2704#issuecomment-228860162 — committed to david-hub024/React_VideoPlayer by deleted user 7 years ago
- Add sourcemap config to uglify plugin No sourcemaps have been generated in `dist` since `0.14.3` https://github.com/webpack/webpack/issues/2704#issuecomment-228860162 — committed to david-hub024/React_VideoPlayer by david-hub024 7 years ago
- Add sourcemap config to uglify plugin No sourcemaps have been generated in `dist` since `0.14.3` https://github.com/webpack/webpack/issues/2704#issuecomment-228860162 — committed to albanqoku/react-player by albanqoku 7 years ago
- Add sourcemap config to uglify plugin No sourcemaps have been generated in `dist` since `0.14.3` https://github.com/webpack/webpack/issues/2704#issuecomment-228860162 — committed to Webmaster1116/video-player by Webmaster1116 7 years ago
- Add sourcemap config to uglify plugin No sourcemaps have been generated in `dist` since `0.14.3` https://github.com/webpack/webpack/issues/2704#issuecomment-228860162 — committed to webmiraclepro/video-player by webmiraclepro 7 years ago
We changed the default, because it’s pretty expensive
Wouldn’t it be better if the plugin detects if a
devtool
has been set, and togglessourceMap
accordingly as a default?I just lost an hour to this issue, speaking of expensive 😦
This should respect the
devtool
setting, or at least detect thatdevtool
is set to produce source maps and emit a warning if the equivalent uglify plugin option is not set.It would also be nice to mention this in the Building for Production docs, because currently it tells us to enable source maps, then to enable UglifyJS, and neglects to mention that the latter disables the former.
This was happening to me, I had to set the
sourceMapFilename
can’t work with
UglifyJsPlugin
andcheap-module-source-map
either, even though I addedsourceMap: true
Doesn’t seem to work:
"mappings":"AAAA"