electron-vue ReferenceError process is not defined
问题:在使用electron-vue时候,运行npn run dev,会出现下面的错误
解决方法:
1、找到根目录下的.electron-vue目录
2、找到该目录下的webpack.renderer.config.js文件,找到这段代码:
new HtmlWebpackPlugin({
  // ...
})
3、用下面的代码将这段代码替换:
new HtmlWebpackPlugin({
      filename: 'index.html',
      template: path.resolve(__dirname, '../src/index.ejs'),
      minify: {
        collapseWhitespace: true,
        removeAttributeQuotes: true,
        removeComments: true
      },
      templateParameters(compilation, assets, options) {
        return {
          compilation: compilation,
          webpack: compilation.getStats().toJson(),
          webpackConfig: compilation.options,
          htmlWebpackPlugin: {
            files: assets,
            options: options
          },
          process,
        };
      },
      nodeModules: process.env.NODE_ENV !== 'production'
        ? path.resolve(__dirname, '../node_modules')
        : false
 }),
4、再找到该目录下的webpack.web.config.js文件,找到这段代码:
new HtmlWebpackPlugin({
  // ...
})
5、用下面的代码将这段代码替换:
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: false
}),
6、最后重新编译就解决了(注意两个文件替换的内容是不一样的)
