electron-builder打包项目并生成安装包的方法,electron打包exe桌面应用。
程序员文章站
2022-06-04 15:15:56
...
1、安装npm install --save electron-builder
2、package.json配置详情。
{
"name": "iden.client",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "electron .",
"pack": "electron-builder --dir",
"build": "electron-builder"
},
"build": {
"appId": "iden.client",
"asar": true,
"directories": {
"buildResources": "build",
"output": "dist"
},
"win": {
"target": [
{
"target": "nsis"
}
],
"icon": "./logo.ico",
"asarUnpack": [
"src/**",
"README.md"
]
},
"nsis": {
"oneClick": false,
"allowElevation": true,
"allowToChangeInstallationDirectory": true,
"installerIcon": "./logo.ico",
"uninstallerIcon": "./logo.ico",
"createDesktopShortcut": true,
"createStartMenuShortcut": true
}
},
"keywords": [],
"author": "[email protected]",
"license": "ISC",
"devDependencies": {
"electron": "^9.0.0",
"electron-builder": "^22.10.5"
}
}
3、直接npm run build.完成。
注意。ico文件至少256*256