
正文
用electrion打包angular成桌面应用
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
用electrion官网的不行。
还好,可以直接照搬 https://github.com/maximegris/angular-electron
安装必要的库
npm i --save-dev electron electron-builder electron-reload npm-run-all wait-on
需要从angular-electron 里复制出来:
./下的
main.ts
tsconfig.json
tsconfig.app.json
tsconfig-serve.json
postinstall.js
postinstall-web.js
electron-builder.json
需要参考修改的: 懒得修改,直接照搬
package.json
"main": "main.js", //增加
"scripts": {
"postinstall": "npm run postinstall:electron && electron-builder install-app-deps",
"postinstall:web": "node postinstall-web",
"postinstall:electron": "node postinstall",
"ng": "ng",
"start": "npm run postinstall:electron && npm-run-all -p ng:serve electron:serve",
"build": "npm run postinstall:electron && npm run electron:serve-tsc && ng build",
"build:dev": "npm run build -- -c dev",
"build:prod": "npm run build -- -c production",
"ng:serve": "ng serve",
"ng:serve:web": "npm run postinstall:web && ng serve -o",
"electron:serve-tsc": "tsc -p tsconfig-serve.json",
"electron:serve": "wait-on http-get://localhost:4200/ && npm run electron:serve-tsc && electron . --serve",
"electron:local": "npm run build:prod && electron .",
"electron:linux": "npm run build:prod && electron-builder build --linux",
"electron:windows": "npm run build:prod && electron-builder build --windows",
"electron:mac": "npm run build:prod && electron-builder build --mac",
"test": "npm run postinstall:web && ng test",
"e2e": "npm run build:prod && mocha --timeout 300000 --require ts-node/register e2e/**/*.spec.ts",
"version": "conventional-changelog -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md",
"lint": "ng lint"
},






