1、问题所在
2、解决方法:
修改.
.electron-vue/webpack.web.config.js
.electron-vue/webpack.renderer.config.js两个文件中的
HtmlWebpackPlugin,添加templateParameters,如下:
```javascript
plugins: [
new VueLoaderPlugin(),
new MiniCssExtractPlugin({filename: 'styles.css'}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.resolve(__dirname, '../src/index.ejs'),
> templateParameters(compilation, assets, options) {
> return {
> compilation: compilation,
> webpack: compilation.getStats().toJson(),
> webpackConfig: compilation.options,
> htmlWebpackPlugin: {
> files: assets,
> options: options
> },
> process,
> };
> },
minify: {
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true
},
nodeModules: process.env.NODE_ENV !== 'production'
? path.resolve(__dirname, '../node_modules')
: false
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin()
],
图中所添加代码行我已标注,单独提取如下:
templateParameters(compilation, assets, options) {
return {
compilation: compilation,
webpack: compilation.getStats().toJson(),
webpackConfig: compilation.options,
htmlWebpackPlugin: {
files: assets,
options: options
},
process,
};
},