这在过去使用手动 webpack 对我有用,但现在对于任何反应项目,无论我使用什么配置,我似乎都无法使用 webpack-dev-server 在开发工具中获得源映射。我尝试了几个 devtools 值,包括“source-map”。我只看到“将文件添加到工作区”而不是“检测到源映射”——有什么想法吗?
chrome 版本 53.0.2785.143(64 位)(mac)
webpack 版本 1.13.2 webpack.config.js
/* eslint-disable */
const path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'inline-source-map',
entry: './app.js',
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
include: __dirname
}]
},
}
最佳答案
终于弄明白了 - 事实证明这是一个 babel 加载器配置问题。将查询参数添加到 babel 加载程序 block 允许我生成源映射:
/* eslint-disable */
const path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'source-map',
entry: './app.js',
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
include: __dirname,
//here
query: {
retainLines: true,
cacheDirectory: true
}
}]
},
}
关于javascript - 无法让 webpack-dev-server (webpack) 在 Chrome 开发工具中生成源映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40010882/