electron-vue Webpack ReferenceError: process is not defined

高版本的node(我是v12.9.1),大于12的版本时候。使用electron-vue项目时候会报错!

 解决方案:修改 .electron-vue/webpack.renderer.config.js 和webpack.web.config.js

如下:webpack.web.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

    }),

如下: webpack.render.config.js

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

    }),

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 原文http://www.cnblogs.com/libin-1/p/6596810.html 版本号 vue-c...
    tengrl阅读 9,152评论 0 0
  • 如何在页面中内嵌js文件 html-webpack-plugin本身不支持此功能,但是提供了相关的实现方式 通过w...
    萧玄辞阅读 3,101评论 0 0
  • webpack 是一个打包工具,进行代码分割,模块通过loader处理各种文件,模块打包器,按需加载,使初始化加载...
    不曾滑落的忧伤阅读 4,189评论 0 1
  • 全局安装webpack 全局安装webpack会有个问题,就是当你有两个项目依赖于不同版本的webpack,就会有...
    説好的妹紙呢阅读 5,879评论 0 11
  • 煜竹阅读 1,135评论 0 0

友情链接更多精彩内容