【开发心得】electron-vue Webpack ReferenceError: process is not defined

前言:前端脚手架迭代越来越快,出现的问题比较多。

问题:

Webpack ReferenceError: process is not defined

 

情况1:

 在src下的index.ejs,注释相关代码。

在这里插入图片描述

解决

在src下的index.ejs里,去掉下面的这段代码:
在这里插入图片描述

参考

使用electron-vue出现Webpack ReferenceError: process is not defined

 情况2:

解决
没有搜索到合适的答案,在GitHub的electron-vue的issue中找到了

方案一
简单粗暴,不知道会不会有什么影响,直接将这段代码去掉


方案二
根据别人在issue里面的写法,.electron-vue/webpack.web.config.js 和.electron-vue/webpack.renderer.config.js中的

在这里插入图片描述
改为

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
    }),
 

posted @ 2021-06-17 22:51  虹梦未来  阅读(51)  评论(0)    收藏  举报  来源