electron builder 打包

本文最后更新于 2024年4月11日 上午

打包环境

  • Mac Apple M2 Pro
  • Node 18.17.0
  • React 18.2.64

配置打包环境

  1. 安装 electron-builder
1
npm i electron-builder --save-dev
  1. package.json 中配置如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"build": {
"extends": null,
"productName": "upload-go",
"copyright": "©Copyright 2023-2024 数字化工作室.",
"appId": "com.upload.team",
"directories": {
"buildResources": "build",
"output": "dist"
},
"files": [
"build/**/*",
"./main.js",
"package.json"
],
"win": {
"target": [
{
"target": "nsis",
"arch": [
"ia32"
]
}
]
},
"nsis": {
"oneClick": false,
"allowElevation": true,
"allowToChangeInstallationDirectory": true,
"installerIcon": "./build/favicon.ico",
"uninstallerIcon": "./build/favicon.ico",
"installerHeaderIcon": "./build/favicon.ico",
"createDesktopShortcut": true,
"createStartMenuShortcut": true,
"shortcutName": "upload-go"
},
"mac": {
"category": "public.app-category.productivity"
},
"dmg": {
"background": "./appdmg.png", // 安装背景图
"icon": "./icon.icns", // 安装icon
"iconSize": 100,
"contents": [
{
"x": 320,
"y": 280,
"type": "link",
"path": "/Applications"
},
{
"x": 110,
"y": 280,
"type": "file"
}
],
"window": {
"width": 500,
"height": 500
}
}
}
  • productName 打包应用名称
  • copyright 应用版权信息
  • appId 针对于mac, 应用签名
  • directories 打包依赖资源
  • files 打包依赖文件
  • win 针对于 windows 打包配置
  • nsis 安装包生成程序 NSIS 的配置
  • mac mac 配置
  • dmg 用于打包 mac 通用配置

打包

1
npm run builder:mac


electron builder 打包
https://dev.dgdream.online/2024/04/06/electron builder 打包/
作者
执念
发布于
2024年4月6日
更新于
2024年4月11日
许可协议