美文网首页
electron-vue报错 ReferenceError: p

electron-vue报错 ReferenceError: p

作者: 梧桐芊雨 | 来源:发表于2020-02-03 12:17 被阅读0次

在使用electron-vue时,运行npm run dev出现如下错误

image.png

解决方式:
找到.electron-vue/webpack.web.config.js 和.electron-vue/webpack.renderer.config.js中的HtmlWebpackPlugin,添加templateParameters,修改后如下:

  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()
  ],

参考:
https://blog.csdn.net/Gabriel_wei/article/details/92785089

https://github.com/SimulatedGREG/electron-vue/issues/871

相关文章

网友评论

      本文标题:electron-vue报错 ReferenceError: p

      本文链接:https://www.haomeiwen.com/subject/hmkhxhtx.html