electron-builder打包配置詳解
這里介紹的是直接在package.json中直接配置使用:
1.基礎(chǔ)配置
"build": { ?// 這里是electron-builder的配置 ? ? "productName":"xxxx",//項目名 這也是生成的exe文件的前綴名 ? ? "appId": "com.xxx.xxxxx",//包名 ? ? ? "copyright":"xxxx",//版權(quán) ?信息 ? ? "directories": { // 輸出文件夾 ? ? ? "output": "build" ? ? },? ? ? // windows相關(guān)的配置 ? ? "win": { ? ? ? ? "icon": "xxx/icon.ico"http://圖標(biāo)路徑? ? ? } ? ? }
2.打包目標(biāo)配置
"win": { ?// 更改build下選項 ? ? "icon": "build/icons/aims.ico", ? ? "target": [ ? ? ? { ? ? ? ? "target": "nsis" // 我們要的目標(biāo)安裝包 ? ? ? } ? ? ] ? },
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",// 安裝圖標(biāo) ? "uninstallerIcon": "./build/icons/bbb.ico",//卸載圖標(biāo) ? "installerHeaderIcon": "./build/icons/aaa.ico", // 安裝時頭部圖標(biāo) ? "createDesktopShortcut": true, // 創(chuàng)建桌面圖標(biāo) ? "createStartMenuShortcut": true,// 創(chuàng)建開始菜單圖標(biāo) ? "shortcutName": "xxxx", // 圖標(biāo)名稱 ? "include": "build/script/installer.nsh", // 包含的自定義nsis腳本 這個對于構(gòu)建需求嚴(yán)格得安裝過程相當(dāng)有用。 },
5.關(guān)于操作系統(tǒng)的配置
CLI參數(shù)
electron-builder --ia32 // 32位 electron-builder ? ? ? ?// 64位(默認(rèn))
nsis中配置
"win": { ? "icon": "build/icons/aims.ico", ? "target": [ ? ? { ? ? ? "target": "nsis", ? ? ? "arch": [ // 這個意思是打出來32 bit + 64 bit的包,但是要注意:這樣打包出來的安裝包體積比較大,所以建議直接打32的安裝包。 ? ? ? ? "x64",? ? ? ? ? "ia32" ? ? ? ] ? ? } ? ] }
6.更新配置
"publish": [ ? { ? ? "provider": "generic", // 服務(wù)器提供商 也可以是GitHub等等 ? ? "url": "http://xxxxx/" // 服務(wù)器地址 ? } ],
完整配置
"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",// 安裝圖標(biāo) ? ? ? "uninstallerIcon": "./build/icons/bbb.ico",//卸載圖標(biāo) ? ? ? "installerHeaderIcon": "./build/icons/aaa.ico", // 安裝時頭部圖標(biāo) ? ? ? "createDesktopShortcut": true, // 創(chuàng)建桌面圖標(biāo) ? ? ? "createStartMenuShortcut": true,// 創(chuàng)建開始菜單圖標(biāo) ? ? ? "shortcutName": "xxxx", // 圖標(biāo)名稱 ? ? ? "include": "build/script/installer.nsh", // 包含的自定義nsis腳本 ? ? }, ? ? "publish": [ ? ? ? { ? ? ? ? "provider": "generic", // 服務(wù)器提供商 也可以是GitHub等等 ? ? ? ? "url": "http://xxxxx/" // 服務(wù)器地址 ? ? ? } ? ? ], ? ? "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
到此這篇關(guān)于electron-builder打包配置詳解的文章就介紹到這了,更多相關(guān)electron-builder打包內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Electron 使? electron-builder 打包應(yīng)用過程詳解
- 使用electron-builder將項目打包成桌面程序的詳細(xì)教程
- vue配置electron使用electron-builder進(jìn)行打包的操作方法
- 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應(yīng)用
相關(guān)文章
用js判斷頁面刷新或關(guān)閉的方法(onbeforeunload與onunload事件)
Onunload,onbeforeunload都是在刷新或關(guān)閉時調(diào)用,可以在<script>腳本中通過window.onunload來指定或者在<body>里指定2012-06-06JS中生成隨機數(shù)的用法及相關(guān)函數(shù)
這篇文章主要為大家介紹了JS中生成隨機數(shù)的用法,為大家提供了相關(guān)函數(shù)的使用方法,感興趣的朋友可以參考一下2016-01-01JavaScript中通過閉包解決只能取得包含函數(shù)中任何變量最后一個值的問題
JavaScript中解決閉包只能取得包含函數(shù)中任何變量最后一個值的問題2010-08-08TypeScript轉(zhuǎn)javaScript的方法示例
本文主要介紹了TypeScript轉(zhuǎn)javaScript的方法示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-06-06