Electron使用electronbuilder工具打包流程

61次阅读

共计 990 个字符,预计需要花费 3 分钟才能阅读完成。

1、安装 electron-builder

npm install  electron-builder --save-dev

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

  • 具体参数可以参考官方文档:https://www.electron.build/configuration/configuration
  • 下面贴出我自己的配置:
{
  "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 目录

正文完
 0