Electron-vue开发框架搭建与注意事项

Electron-vue开发框架搭建与注意事项

初始化项目

electron-vue脚手架项目初始化太慢,即使切换与国内源,依然很慢。有效的方法是先将electron-vue下载下来,再安装样板代码。

  • electron-vue国内码云地址(https://gitee.com/mirrors/electron-vue),直接下载到本地。
  • 或通过git直接克隆到本地 git clone https://gitee.com/mirrors/electron-vue.git
  • 安装样板代码:vue init F:\electron_pro\electron-vue my-project,将“F:\electron_pro\electron-vue”换成自己的地址

安装开发和运行环境

  • npm install
  • npm run dev 调试运行
  • npm run build:win32 打包成windows下的可执行应用程序,打包工具为electron-packager

注意事项

  1. 运行npn run dev,会出现下面的错误

    根据别人在issue里面的写法,.在electron-vue/webpack.web.config.js 和.electron-vue/webpack.renderer.config.js中添加如下代码:
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()
  ]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值