我真的很难让源地图工作。当我运行我的应用程序时,我在控制台中看到错误 - 见下文:
当我点击fineUploaderTest-bundle.js:1
链接时,我得不到任何代码 - 请参阅下文:
在该窗口的底部,注意它显示为:
从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']
}
}
我在这里做错了什么?
答案 0 :(得分:3)
你是如何运行webpack的?我假设在生产模式下你也使用-p
标志?
在生产模式下,Webpack不会输出inline-cheap-module-source-map
类型的源地图(参考:https://webpack.js.org/configuration/devtool/)。
要在生产模式下获得某些输出,我还建议您为inline-cheap-module-source-map
切换source-map
。
答案 1 :(得分:0)