我是webpack的新手,我似乎无法让它配置为生成源地图。这是我的webpack.config.js文件:
var webpack = require("webpack");
var path = require("path");
module.exports = {
devTool: "#source-map",
debug: true,
entry: ['webpack-dev-server/client?http://127.0.0.1:8080/',
'webpack/hot/only-dev-server',
'./src'
],
devServer: {
inline: true,
port:8080
},
output: {
path: path.join(__dirname, 'public'),
filename: 'bundle.js'
},
resolve: {
moduleDirectories: ['../node_modules', 'src'],
extensions: ['', '.js']
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['react-hot', 'babel?presets[]=react,presets[]=es2015']
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin()
]
};
我已经尝试将devTool设置为" eval-source-map"," inline-source-map"等,但没有运气。
Chrome开发者工具未显示任何源地图:
我的package.json:
{
"name": "rcj-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.14.0",
"lodash": "^4.2.1",
"react": "^0.14.7",
"react-dom": "^0.14.7"
},
"devDependencies": {
"babel": "^6.5.2",
"babel-core": "^6.17.0",
"babel-loader": "^6.2.2",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"react-hot-loader": "^1.3.0",
"webpack": "^1.13.3",
"webpack-dev-server": "^1.16.2"
}
}
答案 0 :(得分:2)
webpack配置参数拼写为devtool
,而不是devTool
。
因此devTool: "#source-map"
应为devtool: "#source-map"
。