Webpack - 源地图不工作
Webpack - Source Maps not working
我是 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"
}
}
webpack 配置参数拼写为devtool
,而不是devTool
。
所以devTool: "#source-map"
应该是devtool: "#source-map"
。
我是 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"
}
}
webpack 配置参数拼写为devtool
,而不是devTool
。
所以devTool: "#source-map"
应该是devtool: "#source-map"
。