Electron使用electron-builder工具打包流程

蓝咒 提交于 2020-11-08 16:32:14

1、安装electron-builder

npm install electron-builder --save-dev

 

2、在项目的package.json文件中配置 electron-builder相关参数

{
  "name": "electron-quick-start",
  "version": "1.0.0",
  "description": "A minimal Electron application",
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "build": "electron-builder"
  },
  "build": {
    "appId": "com.imaxue.app",
    "productName":"yangyi",
    "win": {
      "icon": "build/favicon.ico",
      "target": [
        "nsis"
      ]
    },
    "nsis": {
      "oneClick": false,
      "perMachine": true,
      "allowToChangeInstallationDirectory": true
    }
  },
  "repository": "https://github.com/electron/electron-quick-start",
  "keywords": [
    "Electron",
    "quick",
    "start",
    "tutorial",
    "demo"
  ],
  "author": "GitHub",
  "license": "CC0-1.0",
  "devDependencies": {
    "electron": "^8.2.5",
    "electron-builder": "^22.6.1"
  },
  "dependencies": {
    "bootstrap": "^4.5.0",
    "electron-store": "^5.1.1",
    "uuid": "^8.1.0"
  }
}

 

  • 注意要是下载源有问题的话可以在build中添加
 
    "electronDownload":{
      "mirror":"https://npm.taobao.org/mirrors/electron/"
    },

 

3、执行打包命令

npm run build

 

4、完成

完成以后会在项目目录下生成dist目录

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!