electron-builder打包配置詳解
更新時間:2022年01月23日 16:01:08 作者:援筆賦驚鴻
本文主要介紹了electron-builder打包配置詳解,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
這里介紹的是直接在package.json中直接配置使用:
1.基礎配置
"build": { ?// 這里是electron-builder的配置 ? ? "productName":"xxxx",//項目名 這也是生成的exe文件的前綴名 ? ? "appId": "com.xxx.xxxxx",//包名 ? ? ? "copyright":"xxxx",//版權(quán) ?信息 ? ? "directories": { // 輸出文件夾 ? ? ? "output": "build" ? ? },? ? ? // windows相關的配置 ? ? "win": { ? ? ? ? "icon": "xxx/icon.ico"http://圖標路徑? ? ? } ? ? }
2.打包目標配置
"win": { ?// 更改build下選項 ? ? "icon": "build/icons/aims.ico", ? ? "target": [ ? ? ? { ? ? ? ? "target": "nsis" // 我們要的目標安裝包 ? ? ? } ? ? ] ? },
3.其他平臺配置
? "dmg": { // macOSdmg ? ? "contents": [ ? ? ? ... ? ? ] ? ? }, ? ? "mac": { ?// mac ? ? ? "icon": "build/icons/icon.icns" ? ? }, ? ? "linux": { // linux ? ? ? "icon": "build/icons" ? ? }
4.nsis配置
"nsis": { ? "oneClick": false, // 是否一鍵安裝 ? "allowElevation": true, // 允許請求提升。 如果為false,則用戶必須使用提升的權(quán)限重新啟動安裝程序。 ? "allowToChangeInstallationDirectory": true, // 允許修改安裝目錄 ? "installerIcon": "./build/icons/aaa.ico",// 安裝圖標 ? "uninstallerIcon": "./build/icons/bbb.ico",//卸載圖標 ? "installerHeaderIcon": "./build/icons/aaa.ico", // 安裝時頭部圖標 ? "createDesktopShortcut": true, // 創(chuàng)建桌面圖標 ? "createStartMenuShortcut": true,// 創(chuàng)建開始菜單圖標 ? "shortcutName": "xxxx", // 圖標名稱 ? "include": "build/script/installer.nsh", // 包含的自定義nsis腳本 這個對于構(gòu)建需求嚴格得安裝過程相當有用。 },
5.關于操作系統(tǒng)的配置
CLI參數(shù)
electron-builder --ia32 // 32位 electron-builder ? ? ? ?// 64位(默認)
nsis中配置
"win": { ? "icon": "build/icons/aims.ico", ? "target": [ ? ? { ? ? ? "target": "nsis", ? ? ? "arch": [ // 這個意思是打出來32 bit + 64 bit的包,但是要注意:這樣打包出來的安裝包體積比較大,所以建議直接打32的安裝包。 ? ? ? ? "x64",? ? ? ? ? "ia32" ? ? ? ] ? ? } ? ] }
6.更新配置
"publish": [ ? { ? ? "provider": "generic", // 服務器提供商 也可以是GitHub等等 ? ? "url": "http://xxxxx/" // 服務器地址 ? } ],
完整配置
"build": { ? ? "productName":"xxxx",//項目名 這也是生成的exe文件的前綴名 ? ? "appId": "com.leon.xxxxx",//包名 ? ? ? "copyright":"xxxx",//版權(quán) ?信息 ? ? "directories": { // 輸出文件夾 ? ? ? "output": "build" ? ? },? ? ? "nsis": { ? ? ? "oneClick": false, // 是否一鍵安裝 ? ? ? "allowElevation": true, // 允許請求提升。 如果為false,則用戶必須使用提升的權(quán)限重新啟動安裝程序。 ? ? ? "allowToChangeInstallationDirectory": true, // 允許修改安裝目錄 ? ? ? "installerIcon": "./build/icons/aaa.ico",// 安裝圖標 ? ? ? "uninstallerIcon": "./build/icons/bbb.ico",//卸載圖標 ? ? ? "installerHeaderIcon": "./build/icons/aaa.ico", // 安裝時頭部圖標 ? ? ? "createDesktopShortcut": true, // 創(chuàng)建桌面圖標 ? ? ? "createStartMenuShortcut": true,// 創(chuàng)建開始菜單圖標 ? ? ? "shortcutName": "xxxx", // 圖標名稱 ? ? ? "include": "build/script/installer.nsh", // 包含的自定義nsis腳本 ? ? }, ? ? "publish": [ ? ? ? { ? ? ? ? "provider": "generic", // 服務器提供商 也可以是GitHub等等 ? ? ? ? "url": "http://xxxxx/" // 服務器地址 ? ? ? } ? ? ], ? ? "files": [ ? ? ? "dist/electron/**/*" ? ? ], ? ? "dmg": { ? ? ? "contents": [ ? ? ? ? { ? ? ? ? ? "x": 410, ? ? ? ? ? "y": 150, ? ? ? ? ? "type": "link", ? ? ? ? ? "path": "/Applications" ? ? ? ? }, ? ? ? ? { ? ? ? ? ? "x": 130, ? ? ? ? ? "y": 150, ? ? ? ? ? "type": "file" ? ? ? ? } ? ? ? ] ? ? }, ? ? "mac": { ? ? ? "icon": "build/icons/icon.icns" ? ? }, ? ? "win": { ? ? ? "icon": "build/icons/aims.ico", ? ? ? "target": [ ? ? ? ? { ? ? ? ? ? "target": "nsis", ? ? ? ? ? "arch": [ ? ? ? ? ? ? "ia32" ? ? ? ? ? ] ? ? ? ? } ? ? ? ] ? ? }, ? ? "linux": { ? ? ? "icon": "build/icons" ? ? } ? }
參考:github.com/QDMarkMan/CodeBlog/blob/master/Electron/electron-builder
到此這篇關于electron-builder打包配置詳解的文章就介紹到這了,更多相關electron-builder打包內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:
- Electron 使? electron-builder 打包應用過程詳解
- 使用electron-builder將項目打包成桌面程序的詳細教程
- vue配置electron使用electron-builder進行打包的操作方法
- electron-builder打包vue2項目問題總結(jié)
- 快速解決electron-builder打包時下載依賴慢的問題
- vue項目使用electron-builder庫打包成桌面程序的過程
- electron-builder打包exe后白屏的解決方法
- electron-builder 的基本使用及electron打包步驟
- vite?+?electron-builder?打包配置詳解
- Electron 打包問題:electron-builder 下載各種依賴出錯(推薦)
- electron-builder打包與發(fā)布Electron應用
相關文章
用js判斷頁面刷新或關閉的方法(onbeforeunload與onunload事件)
Onunload,onbeforeunload都是在刷新或關閉時調(diào)用,可以在<script>腳本中通過window.onunload來指定或者在<body>里指定2012-06-06JavaScript中通過閉包解決只能取得包含函數(shù)中任何變量最后一個值的問題
JavaScript中解決閉包只能取得包含函數(shù)中任何變量最后一個值的問題2010-08-08TypeScript轉(zhuǎn)javaScript的方法示例
本文主要介紹了TypeScript轉(zhuǎn)javaScript的方法示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-06-06