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,
        };
      },
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐