Electron-builder
lastmod 2022-04-07created 2022-04-073 edits
A complete solution to package and build a ready-for-distribution Electron app for macOS, Windows, and Linux with "auto update" support out of the box.
Build Config
Config example
First, add code like the following to pacakage.json.
"build": {
"productName": "NB",
"appId": "com.nb.electron",
"asar": true,
"mac": {
"target": [
"default"
],
"icon": "build/icons/icon.icns"
},
"dmg": {
"title": "NB",
"icon": "build/icons/icon.icns"
},
"win": {
"target": [
"nsis"
],
"icon": "build/icons/icon.ico"
},
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": false,
"createDesktopShortcut": true,
"perMachine": true,
"language": 1042,
"installerIcon": "build/icons/icon.ico",
"shortcutName": "NB",
"artifactName": "NB-${version}.${ext}",
"uninstallDisplayName": "NB"
},
"directories": {
"buildResources": "./build/",
"output": "./dist/"
}
}
Each key is described below.
-
productionName: application name -
appId: unique application ID -
asar: whether to use asar packaging; bundles the app files together. -
mac: all macOS installer options-
target: defaults to dmg and zip.
-
dmg: DMG build options win: all Windows installer options nsis: NSIS build options-
oneClick: whether to make a one-click installer -
allowToChangeInstallationDirectory: whether the installation directory can be changed -
createDesktopShortcut: whether to add a shortcut to the desktop -
perMachine: whether to always install for all users -
language: installer language (e.g. Korean - 1042) -
installerIcon: path to the installer icon -
shortcutName: name to use for the shortcut -
artifactName: artifact file name -
uninstallDisplayName: display name in the Control Panel's uninstall programs list
directories: build path settings-
buildResources: folder path of the application to build -
output: folder path of the built application
See also
Favorite site
Pages that link here