Sam*_*Sam 9 source-maps webpack
我真的很难让源地图工作.当我运行我的应用程序时,我在控制台中看到错误 - 见下文:
当我点击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']
}
}
Run Code Online (Sandbox Code Playgroud)
我在这做错了什么?
你是如何运行 webpack 的?我假设在生产模式下您也在使用该-p
标志?
inline-cheap-module-source-map
在生产模式下,Webpack 不会输出类型的源映射(参考:https: //webpack.js.org/configuration/devtool/)。
为了在生产模式下获得一些输出,我还建议切换 inline-cheap-module-source-map
为source-map
.
归档时间: |
|
查看次数: |
288 次 |
最近记录: |