Electron Docs
electron-builder configuration can be defined
- in the
package.json
file of your project using thebuild
key on the top level:`
json "build": { "appId": "com.example.app" }`
or through the
--config <path/to/yml-or-json5-or-toml>
option (defaults toelectron-builder.yml
(orjson
, or json5, or toml)).`
yaml appId: "com.example.app"`
If you want to use toml, please install
yarn add toml --dev
.
Most of the options accept null
— for example, to explicitly set that DMG icon must be default volume icon from the OS and default rules must be not applied (i.e. use application icon as DMG icon), set dmg.icon
to null
.
Artifact File Name Template
${ext}
macro is supported in addition to file macros.
Environment Variables from File
Env file electron-builder.env
in the current dir (example). Supported only for CLI usage.
How to Read Docs
- Name of optional property is normal, required is bold.
- Type is specified after property name:
Array<String> | String
. Union like this means that you can specify or string (***", "!foo.js"]
).
Configuration
appId
=com.electron.${name}
String - The application id. Used as CFBundleIdentifier for MacOS and as Application User Model ID for Windows (NSIS target only, Squirrel.Windows not supported). It is strongly recommended that an explicit ID is set.productName
String - As name, but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the name property.copyright
=Copyright © year ${author}
String - The human-readable copyright line for the app.
buildResources
=build
String - The path to build resources.Please note — build resources is not packed into the app. If you need to use some files, e.g. as tray icon, please include required files explicitly:
"files": ["**/*", "build/icon.*"]
output
=dist
String - The output directory.app
String - The application directory (containing the application package.json), defaults toapp
,www
or working directory.
mac
MacConfiguration - Options related to how build macOS targets.mas
MasConfiguration - MAS (Mac Application Store) options.dmg
DmgOptions - macOS DMG options.pkg
PkgOptions - macOS PKG options.
win
WindowsConfiguration - Options related to how build Windows targets.nsis
NsisOptionsnsisWeb
- Web Installer options. Inherits NsisOptions options.appPackageUrl
String - The application package download URL. Optional — by default computed using publish configuration.URL like
https://example.com/download/latest
allows web installer to be version independent (installer will download latest application package). Please note — it is full URL.Custom
X-Arch
http header is set to32
or64
.artifactName
String - The artifact file name template. Defaults to${productName} Web Setup ${version}.${ext}
.
portable
- Portable options.requestExecutionLevel
=user
"user" | "highest" | "admin" - The requested execution level for Windows.
appx
AppXOptionssquirrelWindows
SquirrelWindowsOptions
linux
LinuxConfiguration - Options related to how build Linux targets.deb
DebOptions - Debian package options.snap
SnapOptions - Snap options.appImage
AppImageOptions - AppImage options.pacman
LinuxTargetSpecificOptionsrpm
LinuxTargetSpecificOptionsfreebsd
LinuxTargetSpecificOptionsp5p
LinuxTargetSpecificOptionsapk
LinuxTargetSpecificOptions
buildDependenciesFromSource
=false
Boolean - Whether to build the application native dependencies from source.nodeGypRebuild
=false
Boolean - Whether to executenode-gyp rebuild
before starting to package the app.Don't usenpm (neither
.npmrc
) for configuring electron headers. Useelectron-builder node-gyp-rebuild
instead.npmArgs
Array<String> | String - Additional command line arguments to use when installing app native deps.npmRebuild
=true
Boolean - Whether to rebuild native dependencies before starting to package the app.
buildVersion
String - The build version. Maps to theCFBundleVersion
on macOS, andFileVersion
metadata property on Windows. Defaults to theversion
. IfTRAVIS_BUILD_NUMBER
orAPPVEYOR_BUILD_NUMBER
orCIRCLE_BUILD_NUM
orBUILD_NUMBER
orbamboo.buildNumber
env defined, it will be used as a build version (version.build_number
).electronCompile
Boolean - Whether to use electron-compile to compile app. Defaults totrue
ifelectron-compile
in the dependencies. Andfalse
if in thedevDependencies
or doesn't specified.electronDist
String - The path to custom Electron build (e.g.~/electron/out/R
).electronDownload
- The electron-download options.cache
String - The cache location.mirror
String - The mirror.quiet
BooleanstrictSSL
BooleanverifyChecksum
Boolean
electronVersion
String - The version of electron you are packaging for. Defaults to version ofelectron
,electron-prebuilt
orelectron-prebuilt-compile
dependency.extends
String - The name of a built-in configuration preset or path to config file (relative to project dir). Currently, onlyreact-cra
is supported.If
react-scripts
in the app dev dependencies,react-cra
will be set automatically. Set tonull
to disable automatic detection.extraMetadata
any - Inject properties topackage.json
.
forceCodeSigning
=false
Boolean - Whether to fail if the application is not signed (to prevent unsigned app if code signing configuration is not correct).muonVersion
String - The version of muon you are packaging for.
afterPack
(context: AfterPackContext) => Promise | null - The function (or path to file or module id) to be run after pack (but before pack into distributable format and sign).beforeBuild
(context: BeforeBuildContext) => Promise | null - The function (or path to file or module id) to be run before dependencies are installed or rebuilt. Works whennpmRebuild
is set totrue
. Resolving tofalse
will skip dependencies install or rebuild.
Following options can be set also per platform (top-level keys mac, linux and win).
{% include "/generated/PlatformSpecificBuildOptions.md" %}
Metadata
Some standard fields should be defined in the package.json
.
{% include "/generated/Metadata.md" %}
Build Version Management
CFBundleVersion
(macOS) and FileVersion
(Windows) will be set automatically to version.build_number
on CI server (Travis, AppVeyor, CircleCI and Bamboo supported).
相关npm包集合
- electron-packager
- electron-builder
- electron-updater
- electron-download
- electron-apps
- electron-to-chromium
- awesome-electron
- electron-debug
- electron-rebuild