-
Notifications
You must be signed in to change notification settings - Fork 9
/
forge.config.js
115 lines (112 loc) · 3.27 KB
/
forge.config.js
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* eslint-disable */
const fsPromises = require("fs/promises");
const fs = require("fs");
const path = require("path");
async function prunePackageJson(buildPath) {
const packageDotJsonPath = path.join(buildPath, "package.json");
const content = await fsPromises.readFile(packageDotJsonPath);
const json = JSON.parse(content.toString());
Object.keys(json).forEach((key) => {
switch (key) {
case 'name': {
break;
}
case 'version': {
break;
}
case 'main': {
break;
}
case 'author': {
break;
}
case 'description': {
break;
}
default: {
delete json[key];
break;
}
}
});
await fsPromises.writeFile(packageDotJsonPath, JSON.stringify(json, null, "\t"));
}
module.exports = {
packagerConfig: {
name: "TinySSH",
appCopyright: "Copyright (C) 2024",
icon: "./src/main/static/icon",
// ElectronForge默认会将项目根目录下的所有文件及目录打包到resources
// 因此需要在这里忽略不需要打入到安装包的文件和目录
// 对于node_modules目录,只会打包dependencies依赖项
// 不支持正则表达式
ignore: [
".vscode",
"node_modules/.vite",
"node_modules/.ignored",
"node_modules/.cache",
"README.md",
"yarn.lock",
"vite.config.js",
"forge.config.js",
".gitignore",
".eslintrc.js",
".eslintignore",
".prettierignore",
".prettierrc.js",
"LICENSE",
"^(\/src$)",
"^(\/scripts$)",
"^(\/out$)",
"^(\/setup$)",
"^(\/screenshot$)",
],
win32metadata: {
ProductName: "TinySSH",
CompanyName: "",
FileDescription: "TinySSH",
// 如果安装包需要以管理员权限运行,请打开下面的注释
// "requested-execution-level": "requireAdministrator",
},
// 是否使用asar压缩资源
asar: true,
},
// 定义钩子,更多钩子请参考:https://www.electronforge.io/config/hooks
hooks: {
// 在文件拷贝完成后触发
packageAfterCopy: async(config, buildPath, electronVersion, platform, arch) => {
// 比如在拷贝完成后需要删除src目录
//await fsPromises.rmdir(path.join(buildPath, "src"), { recursive: true });
// 精简package.json,删除无需暴露的属性
await prunePackageJson(buildPath);
},
},
rebuildConfig: {},
// Maker用于最终生成对应平台的安装包
// 更多Maker请参考:https://www.electronforge.io/config/makers
makers: [
{
// 仅支持Windows平台
name: "@electron-forge/maker-squirrel",
config: {
// 用于数字签名的证书路径和密码
// certificateFile: './cert.pfx',
// certificatePassword: process.env.CERTIFICATE_PASSWORD
},
},
{
// 仅支持macOS平台
name: "@electron-forge/maker-dmg",
config: {
icon: "./src/main/static/icon.icns",
// 背景图片
// background: './assets/dmg-background.png',
format: "ULFO",
},
},
{
// 创建一个zip压缩包,支持所有平台
name: "@electron-forge/maker-zip",
},
],
}