gpt4 book ai didi

javascript - 源映射不是由 WebPack 生成的

转载 作者:搜寻专家 更新时间:2023-11-01 05:03:31 26 4
gpt4 key购买 nike

诚然,我对source mapswebpack 有基本的了解。据我了解,如果我在 webpack.config.js 文件中正确设置了 devtools,我应该会得到映射到原始代码的源映射文件。

我正在使用以下配置文件,但没有获得任何源映射文件。知道为什么吗?

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({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin({
minimize: true,
compress: true,
output: { comments: false }
})
];

var _devtool = IS_DEV ? 'eval' : '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: './components/login/login.jsx',
home: './components/home/home.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']
}
}

最佳答案

根据文档,

When using the uglifyjs-webpack-plugin you must provide the sourceMap: true option to enable SourceMap support.

关于javascript - 源映射不是由 WebPack 生成的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47610871/

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