这是我的配置文件片段:
new webpack.optimize.UglifyJsPlugin({
exclude:'/.*\/node_modules\/.*/',
compress: {
unused: true,
drop_console: false,
drop_debugger: true,
dead_code: true,
properties: false,
warnings: false,
screw_ie8: false,
},
mangle: {
screw_ie8: false,
},
output: {
screw_ie8: false,
},
comments: false,
})
...
new HtmlWebpackPlugin({
devscript: process.env.NODE_ENV === 'production' ? '' : scriptInject,
filename: filename_ssr,
template: template_ssr,
inject: false
})
错误是:
Html Webpack Plugin:
<pre>
Error: The loader "/Users/xiexing/work/code/static.g.iqiyi.com/game/react/node _modules/_html-webpack-plugin@2.30.1@html-webpack-plugin/lib/loader.js!/Users/ xiexing/work/code/static.g.iqiyi.com/game/react/node_modules/_html-webpack-plu gin@2.30.1@html-webpack-plugin/default_index.ejs" didn't return html.
</pre>
但是,如果我删除了webpack.optimize.UglifyJsPlugin,那么一切都会正常运行,并且会使用源代码进行调试。并发现其中有一个source
变量的值是js文件的代码,例如:var HTML_WEBPACK_PLUGIN_RESULT ...,该js已被压缩,如果我删除webpack.optimize.UglifyJsPlugin,则该js将被解压缩并正常工作。 / p>