使用 electron-builder 打包应用
(1)安装 electron-builder
1npm install electron-builder -D
(2)在 package.json
中进行相关配置
1{
2 "name": "learn_electron",
3 "version": "1.0.0",
4 "description": "this is a electron demo",
5 "main": "main.js",
6 "scripts": {
7 "start": "electron .",
8 "build": "electron-builder"
9 },
10 "build": {
11 "appId": "com.dancy.learn_electron",
12 "win": {
13 "icon": "./logo.ico",
14 "target": [
15 {
16 "target": "nsis",
17 "arch": [
18 "x64"
19 ]
20 }
21 ]
22 },
23 "nsis": {
24 "oneClick": false,
25 "perMachine": true,
26 "allowToChangeInstallationDirectory": true
27 }
28 },
29 "keywords": [],
30 "author": "dancy",
31 "license": "ISC",
32 "devDependencies": {
33 "electron": "^33.2.0",
34 "electron-builder": "^25.1.8"
35 }
36}
(3)执行打包命令
1npm run build