Electron开发(二)----创建工程

创建工程

npm install -g vue-cli                            //全局安装
cd 目录路径
vue init simulatedgreg/electron-vue my-project    //创建工程
yarn 						//安装依赖
yarn dev					//运行项目

在首次运行时间,我出现process is not defined错误。解决办法是: 在 .electron-vue/webpack.renderer.config.js.electron-vue/webpack.web.config.js文件中找到HtmlWebpackPlugin代码段并更改为如下代码:

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

再次运行

yarn dev

打开微信扫一扫关注小程序

文章请注明出处:https://www.suzf.top/archives/Electron%E5%BC%80%E5%8F%91%EF%BC%88%E4%BA%8C%EF%BC%89----%E5%88%9B%E5%BB%BA%E5%B7%A5%E7%A8%8B

# Electron 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×