我已经开发了角电子应用程序。它是一个简单的应用程序,但是它的大小为159Mb。我使用电子生成器来构建电子应用程序并包含自动更新包。当我解压缩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": "**********"
}
}
还有其他方法可以减小电子应用程序的文件大小
答案 0 :(得分:1)
您可以在compression
中将package.json
的级别从“正常”更改为“最大”:
"build": {
"appId": "com.electron.example",
"compression": "maximum",
// other build settings
}
这将为您节省大约100MB的应用空间。
检查electron-builder
docs了解更多信息。