我有一个 Electron 应用程序(使用 Angular 制作)并使用此模板: https ://github.com/iffy/electron-updater-example
每次我运行 electron builder 命令时,应用程序本身的大小都会增加 10MB。当我在 Windows 或 Linux 中构建时,也会发生同样的情况。Windows 安装程序当前为 337MB,开始时大约为 60MB。
这是 package.json 中的脚本部分:
"build": "npm run electron:serve-tsc && ng build",
"build:electron": "npm run build -- -c production --aot=true --build-optimizer=true --output-path=electron --base-href ./",
"electron:serve-tsc": "tsc -p tsconfig.serve.json",
"electron:build": "npm run build:electron && electron-builder build"
我跑:
npm run electron:build
以下是电子设置:
{
"productName": "APP NAME",
"compression": "maximum",
"directories": {
"output": "release/",
"buildResources": "electron/"
},
"files": [
"**/*",
"electron",
"!**/*.ts",
"!*.code-workspace",
"!LICENSE.md",
"!package.json",
"!package-lock.json",
"!src/",
"!e2e/",
"!hooks/",
"!angular.json",
"!_config.yml",
"!karma.conf.js",
"!tsconfig.json",
"!tslint.json"
],
"publish": {
"provider": "generic",
"url": "https://example.com/downloads/"
},
"win": {
"artifactName": "${productName} Setup.${ext}",
"icon": "electron/assets/icons/electron",
"target": [
"nsis"
]
},
"mac": {
"icon": "electron/assets/icons/electron",
"target": [
"dmg"
]
},
"linux": {
"artifactName": "${productName} Setup.${ext}",
"executableName": "APP NAME",
"icon": "electron/assets/icons/electron",
"target": {
"target": "appimage",
"arch": ["armv7l"]
}
},
"nsis": {
"installerIcon": "electron/assets/icons/electron/favicon.ico",
"uninstallerIcon": "electron/assets/icons/electron/favicon.ico",
"uninstallDisplayName": "${productName}",
"runAfterFinish": true,
"oneClick": false,
"allowToChangeInstallationDirectory": true
}
}
构建器是否需要某种清理命令?如何阻止应用程序增加大小?非常感谢您的帮助!