gpt4 book ai didi

javascript - 如何为 WebPack 创建源映射?

转载 作者:数据小太阳 更新时间:2023-10-29 05:05:29 25 4
gpt4 key购买 nike

我当前的 webpack.config 文件

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" }
]
},
};

我在这里阅读https://webpack.github.io/docs/configuration.html并发现以下内容:

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.

如您所见,我已经在上面添加了它,但是当我的 webpack watch 运行时,我没有看到 map 文件?

这是怎么做到的?

最佳答案

这里有两个选项:

使用 CLI development shortcut连同您的 --watch 选项:

webpack -d --watch

或使用配置devtool 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" }
]
},
};

关于javascript - 如何为 WebPack 创建源映射?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33786232/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com