electron-builder
The templates currently used are packaged and built using electron-builder.So we need to understand his configuration and better customize program packaging.
electron-builder.json5
json5
/**
* @see https://www.electron.build/configuration/configuration
*/
{
"appId": "YourAppID",
"asar": false,
"productName": "YourAppName",
"directories": {
"output": "release/${version}"
},
"files": [
"dist",
"dist-electron"
],
"win": {
"target": [
{
"target": "nsis",
"arch": ["x64"]
}
],
"artifactName": "${productName}-Windows-${version}-Setup.${ext}"
},
"nsis": {
"oneClick": false,
"perMachine": false,
"allowToChangeInstallationDirectory": true,
"deleteAppDataOnUninstall": false
},
"mac": {
"target": ["dmg"],
"artifactName": "${productName}-Mac-${version}-Installer.${ext}"
},
"linux": {
"target": ["AppImage"],
"artifactName": "${productName}-Linux-${version}.${ext}"
}
}
appId
The unique identifier of an application.
- usually a reverse domain name (such as com. example. myapp). When publishing an application, you need to use the same values in the package name and ID.
中文
应用程序的唯一标识符。productName
The name of the application.
中文
应用程序的名称。asar
Whether to package the application files into an asar file.
- asar is a zip like archive format that can reduce the size of application packages.
中文
asar 是否将应用程序文件打包成一个 asar 文件。directories
Contains some directory configurations.
- output specifies the output directory of the application package. The ${version} variable is used here to indicate that a directory corresponding to the application version number will be created in the output directory.
中文
包含了一些目录配置。files
The files and directories included in the application:dist-electron and dist..
- dist-electron contains the code of the Electron application.
- dist contains other resources of the application (such as HTML, CSS, images, etc.).
中文
应用程序包含的文件和目录:dist-electron 和 dist。linux
Specific configurations for the linux platform.
- icon The icon file for the application is set here. Usually, you need to place the icon file in the application package and specify its relative path here.
中文
linux 平台的特定配置。mac
Specific configurations for the macOS platform.
- icon Icon is the name of the application, and version is the version number of the application.
- target The target for application packaging has been specified, set to dmg here, which means packaging the application into a macOS installation program.
- artifactName The file name of the application package was specified, where the ${productName} and ${version} variables were used. ProductName is the name of the application, and version is the version number of the application.
中文
macOS 平台的特定配置。win
Specific configurations for the Windows platform.
- icon Icon is the name of the application, and version is the version number of the application.
- target The target for application packaging has been specified, where it is set to nsis, which means packaging the application into a Windows installation program.
- target The target for application packaging has been specified, where it is set to nsis, which means packaging the application into a Windows installation program.
- arch The specified CPU architecture for packaging is set to x64, indicating that only 64 bit Windows is packaged.
- artifactName The file name of the application package was specified, where the ${productName} and ${version} variables were used. ProductName is the name of the application, and version is the version number of the application.
中文
Windows 平台的特定配置。- target
- target 指定了应用程序打包的目标,这里设置为 nsis,表示将应用程序打包成一个 Windows 安装程序。
- arch 指定了打包的 CPU 架构,这里设置为 x64,表示仅打包 64 位 Windows。
nsis
Windows platform specific NSIS configuration.
- oneClick specifies whether to enable one click installation mode.
- perMachine specifies whether to install for all users.
- allowToChangeInstallationDirectory specifies whether users are allowed to change the installation directory.
- deleteAppDataOnUninstall specifies whether to delete user data when uninstalling the application.
中文
Windows平台特定的 NSIS 配置。Build Scripts
json
"scripts": {
"build-mac": "electron-builder build --mac",
"build-win": "electron-builder build --win",
"build-linux": "electron-builder build --linux",
}
More
If you want to know more about the configuration, please refer to the electron-build/configuration documentation.