gpt4 book ai didi

webpack - 源映射无法与 Webpack 一起使用

转载 作者:行者123 更新时间:2023-12-02 07:31:59 25 4
gpt4 key购买 nike

我对 webpack 还很陌生,在配置它来生成必要的源映射时遇到了一些麻烦。在开发工具中它说

Source Map detected

但它显示的是 bundle 而不是原始代码:

screen shot 2016-06-20 at 18 04 05

这是我的 webpack.config.js:

module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:8080/',
'webpack/hot/dev-server',
"./src/index.js"
],
output: {
filename: 'bundle.js',
path: '/',
},
debug: true,
devtool: 'source-map',
resolve: {
extensions: ['', '.jsx', '.scss', '.js', '.json']
},
module: {
loaders: [
{
test: /(\.js|\.jsx)$/,
exclude: /node_modules/,
loaders: ['react-hot','babel']
},
{
test: /\.scss$/,
exclude: /node_modules/,
loaders: ["style", "css?sourceMap", "sass?sourceMap"]
}
]
},
devServer: { hot: true },
plugins: [ new webpack.HotModuleReplacementPlugin() ],
inline: true,
progress: true,
colors: true
};

这是我的 package.json:

{
"name": "react-template",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"dev:test": "./node_modules/.bin/webpack --config webpack.test.config.js",
"test:bundle": "./node_modules/.bin/tape test/bundle.js",
"dev:serve": "./node_modules/.bin/webpack-dev-server --config webpack.development.config.js"
},
"devDependencies": {
"babel-loader": "^6.2.1",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"css-loader": "^0.23.1",
"node-sass": "^3.8.0",
"on-build-webpack": "^0.1.0",
"react": "^0.14.6",
"react-dom": "^0.14.6",
"react-hot-loader": "^1.3.0",
"sass-loader": "^3.2.1",
"style-loader": "^0.13.0",
"tape": "^4.4.0",
"webpack": "^1.12.12",
"webpack-dev-server": "^1.14.1"
}
}

我尝试了 devtool 选项的多种变体并阅读了 this , thisthis但没有运气。

任何帮助都会很棒!

最佳答案

bundle.js 中,您将看到原始的转译 webpack 包 - 这是正常行为。

打开webpack://,您将看到您的项目文件。

enter image description here

关于webpack - 源映射无法与 Webpack 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37928165/

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