问题
My current webpack.config
file
module.exports = {
entry: "./entry.js",
output: {
devtoolLineToLine: true,
sourceMapFilename: "./bundle.js.map",
pathinfo: true,
path: __dirname,
filename: "bundle.js"
},
module: {
loaders: [
{ test: /\.css$/, loader: "style!css" }
]
},
};
I was reading here https://webpack.github.io/docs/configuration.html and found the following:
output.sourceMapFilename
[file] is replaced by the filename of the JavaScript file.
[id] is replaced by the id of the chunk.
[hash] is replaced by the hash of the compilation.
I've added it above as you can see, but when my webpack watch runs, I don't see a map file?
How is this done?
回答1:
There are two options here:
Using the CLI development shortcut along with your --watch
option:
webpack -d --watch
or using the configuration devtool option in your webpack.config.js
:
module.exports = {
devtool: "source-map",
entry: "./entry.js",
output: {
devtoolLineToLine: true,
sourceMapFilename: "./bundle.js.map",
pathinfo: true,
path: __dirname,
filename: "bundle.js"
},
module: {
loaders: [
{ test: /\.css$/, loader: "style!css" }
]
},
};
来源:https://stackoverflow.com/questions/33786232/how-to-create-a-source-map-for-webpack