我似乎无法获得Webpack2生成JS源地图。我想也许删除Closure Compiler插件可以修复它,但不会。Webpack2不生成JS源地图
我的设置:
- 的WebPack 2.4.1
- 的WebPack闭合编译器2.1.4
命令我运行:
webpack -d --colors --progress
我的WebPack配置:
const path = require('path')
const DefinePlugin = require('webpack').DefinePlugin
const CopyWebpackPlugin = require('copy-webpack-plugin')
const ClosureCompilerPlugin = require('webpack-closure-compiler')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
module.exports = {
devtool: 'source-map',
entry: {
'client-bundle': path.join(__dirname, 'src/index')
},
module: {
rules: [
{
test: [ /\.jsx?$/ ],
include: [/src/],
loader: 'babel-loader',
exclude: [/\.test.js$/]
},
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.html?$/, loader: 'html-loader' },
{ test: /\.(css|sass)$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader!postcss-loader!sass-loader' }) },
{ test: /\.(png|jpg|jpeg|gif|ico)$/, loader: 'file-loader?name=[path][name].[ext]' },
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=10000&minetype=application/font-woff' },
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'file-loader' }
]
},
output: {
filename: '[name].js',
library: '[name]',
libraryTarget: 'this',
path: path.join(__dirname, 'dist')
},
plugins: [
new CopyWebpackPlugin([
{from: path.join(__dirname, 'src/index.html')}
]),
new ClosureCompilerPlugin({
compiler: {
language_in: 'ECMASCRIPT6',
language_out: 'ECMASCRIPT5',
compilation_level: 'SIMPLE'
},
concurrency: 3
}),
new DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('development')
}
})
],
target: 'web'
}
我试图在这里指出devtool
每一个可能的值:https://webpack.js.org/configuration/devtool/。我已经尝试在Closure Compiler配置中将create_source_map: true
添加到compiler
对象中。似乎没有任何工作。这不是权限问题,因为生成的包很好。
编辑:
所以我改变了的WebPack命令使用-p
选项,而不是-d
。这产生了一个错误:
ERROR in client.js from UglifyJs
TypeError: Cannot read property 'sections' of null
这很奇怪,因为我没有使用UglifyJS插件。但是,我只能通过移除Closure Compiler Plugin来消除错误。现在事情正确地构建,并生成一个源地图,但我没有压缩。