Get the App
SLTechnology News&Howtos  ›  Development  › 

How to package and configure electron-builder

Shulou Source: shulou.com Published: 2022-06-01 23:49:23 10月05日 Update

How to package and configure electron-builder? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

The editor introduces the direct configuration and use in package.json:

1. Basic configuration "build": {/ / here is the configuration of electron-builder "productName": "xxxx", / / the project name, which is also the prefix name of the generated exe file "appId": "com.xxx.xxxxx", / / package name "copyright": "xxxx", / / copyright information "directories": {/ / output folder "output": "build"} / / windows-related configuration "win": {"icon": "xxx/icon.ico" / / icon path}} 2. Package target configuration "win": {/ / change the options under build "icon": "build/icons/aims.ico", "target": [{"target": "nsis" / / the target installation package we want}]}, 3. Other platform configurations "dmg": {/ / macOSdmg "contents": [...]}, "mac": {/ / mac "icon": "build/icons/icon.icns"}, "linux": {/ / linux "icon": "build/icons"} 4.nsis configuration "nsis": {"oneClick": false / / whether to install "allowElevation": true with one click, / / allow request for promotion. If false, the user must restart setup with elevated privileges. "allowToChangeInstallationDirectory": true, / / allows you to modify the installation directory "installerIcon": ". / build/icons/aaa.ico", / / installation icon "uninstallerIcon": ". / build/icons/bbb.ico", / / uninstall icon "installerHeaderIcon": ". / build/icons/aaa.ico", / / install header icon "createDesktopShortcut": true, / / create desktop icon "createStartMenuShortcut": true / / create the start menu icon "shortcutName": "xxxx", / / the icon name "include": "build/script/installer.nsh", / / contains custom nsis scripts that are useful for building the installation process that requires strict requirements. }, 5. About the configuration of the operating system

CLI parameter

Electron-builder-ia32 / / 32-bit electron-builder / / 64-bit (default)

Configuration in nsis

"win": {"icon": "build/icons/aims.ico", "target": [{"target": "nsis", "arch": [/ / this means typing out a package of 32 bit + 64 bit, but note: the installation package packaged in this way is relatively large, so it is recommended to hit the 32 installation package directly. "x64", "ia32"]}]} 6. Update configuration "publish": [{"provider": "generic", / / server provider can also be GitHub, etc. "url": "http://xxxxx/" / / server address}]

Complete configuration

"build": {"productName": "xxxx", / / Project name this is also the prefix name of the generated exe file "appId": "com.leon.xxxxx", / / package name "copyright": "xxxx", / / copyright information "directories": {/ / output folder "output": "build"}, "nsis": {"oneClick": false / / whether to install "allowElevation": true with one click, / / allow request for promotion. If false, the user must restart setup with elevated privileges. "allowToChangeInstallationDirectory": true, / / allows you to modify the installation directory "installerIcon": ". / build/icons/aaa.ico", / / installation icon "uninstallerIcon": ". / build/icons/bbb.ico", / / uninstall icon "installerHeaderIcon": ". / build/icons/aaa.ico", / / install header icon "createDesktopShortcut": true, / / create desktop icon "createStartMenuShortcut": true / / create the start menu icon "shortcutName": "xxxx", / / Icon name "include": "build/script/installer.nsh", / / Custom nsis script included}, "publish": [{"provider": "generic" / / the server provider can also be GitHub, etc. "url": "http://xxxxx/" / / server address}]," files ": [" dist/electron/**/* "]," dmg ": {" contents ": [{" x ": 410," y ": 150 "type": "link", "path": "/ Applications"}, {"x": 130,150, "type": "file"}]}, "mac": {"icon": "build/icons/icon.icns"} "win": {"icon": "build/icons/aims.ico", "target": [{"target": "nsis", "arch": ["ia32"]}]} "linux": {"icon": "build/icons"}} answers to questions about how electron-builder should be packaged and configured are shared here. I hope the above content can help you to a certain extent, if you still have a lot of doubts to be solved, you can follow the industry information channel to learn more related knowledge.

Tags: Configuration icons files servers services questions information prefixes names addresses headers providers folders more permissions desktops copyrights users directories targets Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MySQL Shulou Tech Info NVidia Microsoft