gpt4 book ai didi

javascript - 无法让 webpack-dev-server (webpack) 在 Chrome 开发工具中生成源映射

转载 作者:行者123 更新时间:2023-11-30 00:02:10 33 4
gpt4 key购买 nike

这在过去使用手动 webpack 对我有用,但现在对于任何反应项目,无论我使用什么配置,我似乎都无法使用 webpack-dev-server 在开发工具中获得源映射。我尝试了几个 devtools 值,包括“source-map”。我只看到“将文件添加到工作区”而不是“检测到源映射”——有什么想法吗?

chrome 版本 53.0.2785.143(64 位)(mac)

  • 开发者工具实验标志已启用

    • enter image description here

webpack 版本 1.13.2webpack.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
}]
},
}

dev tools - no sourcemap

最佳答案

终于弄明白了 - 事实证明这是一个 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/

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