gpt4 book ai didi

webpack - 使源 map 正常工作

转载 作者:行者123 更新时间:2023-12-04 04:28:42 24 4
gpt4 key购买 nike

我真的在努力使源 map 正常工作。当我运行我的应用程序时,我在控制台中看到一个错误-参见下文:
enter image description here

当我单击fineUploaderTest-bundle.js:1链接时,我什么也看不到代码-参见下文:
enter image description here

在该窗口的底部,请注意它显示为:

source mapped from fineUploaderTest-bundle.js



我的Webpack版本是2.7.0,这是 webpack.config.js文件:
var IS_DEV = false;

var webpack = require('webpack');
var path = require("path");

// Define plugins needed for production and dev cases
var _pluginsDev = [
new webpack.ProvidePlugin({
'fetch': 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch',
moment: 'moment',
ps: 'perfect-scrollbar'
}),

];
var _pluginsProd = [
new webpack.ProvidePlugin({
'fetch': 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch',
moment: 'moment',
ps: 'perfect-scrollbar'
}),
new webpack.DefinePlugin({ // Minimizer, removing multiple occurances of imports et.c
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin({
minimize: true,
compress: true,
sourceMap: true,
output: { comments: false }
})
];

var _devtool = IS_DEV ? 'eval' : 'inline-cheap-module-source-map';
var _plugins = IS_DEV ? _pluginsDev : _pluginsProd;
var _fileName = IS_DEV ? "./build/[name]-bundle.js" : "./dist/[name]-bundle.js";

var _bundles = {
login: './UI/components/login/login.jsx',
fineUploaderTest: './UI/components/test.jsx'
};

module.exports = {
entry: _bundles,
output: {
path: path.resolve(__dirname, "wwwroot"),
publicPath: "/",
filename: _fileName
},
devtool: _devtool,
plugins: _plugins,
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: "babel-loader",
options: {
presets: ['es2015', 'stage-2', 'stage-0', 'react']
}
}
}
]
},
resolve: {
extensions: ['.js', '.jsx']
}
}

我在这里做错了什么?

最佳答案

您如何运行webpack?我假设在生产模式下您还使用了-p标志?

在生产模式下,Webpack不会输出inline-cheap-module-source-map类型的源映射(引用:https://webpack.js.org/configuration/devtool/)。

为了在生产模式下获得一些输出,我还建议将inline-cheap-module-source-map切换为source-map

关于webpack - 使源 map 正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47762129/

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