gpt4 book ai didi

electron - 压缩 Electron 应用程序的大小

转载 作者:行者123 更新时间:2023-12-03 12:25:52 25 4
gpt4 key购买 nike

我开发了 angular-electron 应用程序。它是一个简单的应用程序,但它的大小为 159Mb。我使用 Electron 生成器来构建 Electron 应用程序并包含自动更新包。当我解压缩 asar 文件时,它有节点模块。当我指定不在 package.json 中包含节点模块,应用程序的大小减少到 89mb,但应用程序没有运行。
这是我的 package.json

{
"name": "example",
"version": "0.1.2",
"main": "main.js",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"dist": "electron-builder",
"electron": "ng build --base-href ./ && electron .",
"build:electron": "electron-builder build --mac --win --publish never",
"deploy": " electron-builder build --publish always"
},
"private": true,
"dependencies": {
"@angular/animations": "~7.0.0",
"@angular/cdk": "^7.3.7",
"@angular/common": "~7.0.0",
"@angular/compiler": "~7.0.0",
"@angular/core": "~7.0.0",
"@angular/forms": "~7.0.0",
"@angular/http": "~7.0.0",
"@angular/material": "^7.3.7",
"@angular/platform-browser": "~7.0.0",
"@angular/platform-browser-dynamic": "~7.0.0",
"@angular/router": "~7.0.0",
"core-js": "^2.5.4",
"electron-updater": "^4.2.0",
"ngx-electron": "^2.2.0",
"rxjs": "~6.3.3",
"v8-compile-cache": "^2.1.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.10.0",
"@angular/cli": "~7.0.7",
"@angular/compiler-cli": "~7.0.0",
"@angular/language-service": "~7.0.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"electron": "^7.1.2",
"electron-builder": "^21.2.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"rimraf": "^3.0.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.6"
},
"build": {
"appId": "com.electron.example",
"compression": "normal",
"extends": null,
"files": [
"*.js",
"build",
"dist",
"renderer",
"!node_modules"
],
"mac": {
"target": "zip"
},
"linux": {
"target": [
"AppImage",
"zip"
]
},
"win": {
"target": [
"NSIS",
"zip"
]
},
"publish": {
"provider": "github",
"repo": "Example",
"owner": "y***y",
"token": "1234567"
}
},
"repository": {
"type": "git",
"url": "**********"
}
}

有没有其他方法可以减少 Electron 应用程序的文件大小

最佳答案

您可以更改compression package.json 中从“正常”到“最大”的水平:

"build": {
"appId": "com.electron.example",
"compression": "maximum",
// other build settings
}
这通常应该是 在应用程序大小方面为您节省很多 取决于您之前的压缩设置以及您在构建中拥有多少静态文件和添加的功能、代码和/或依赖项。

更新
无论如何,如果您的应用程序相对接近〜80Mb,您将不会节省很多,因为这通常是 Electron 构建的大小(包含节点、 Chrome 和 API ..)。
查看 electron-builder docs了解更多信息。

关于electron - 压缩 Electron 应用程序的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59280718/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com