Common Configuration
electron-builder configuration can be defined
- in the
package.json
file of your project using thebuild
key on the top level:"build": { "appId": "com.example.app" }
-
or through the
--config <path/to/yml-or-json5-or-toml-or-js>
option. Defaults toelectron-builder.yml
.appId: "com.example.app"
json
, json5, toml orjs
/ts
(exported configuration or function that produces configuration) formats also supported.Tip
If you want to use
js
file, do not name itelectron-builder.js
. It will conflict withelectron-builder
package name.Tip
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 (**/*
), or array of strings (["**/*", "!foo.js"]
).
Configuration¶
appId
=com.electron.${name}
String | “undefined” - 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 | “undefined” - 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. If not specified inside of thebuild
configuration,productName
property defined at the top level ofpackage.json
is used. If not specified at the top level ofpackage.json
, name property is used.copyright
=Copyright © year ${author}
String | “undefined” - The human-readable copyright line for the app.
directories
MetadataDirectories | “undefined”
mac
MacConfiguration - Options related to how build macOS targets.mas
MasConfiguration - MAS (Mac Application Store) options.masDev
MasConfiguration - MAS (Mac Application Store) development options (mas-dev
target).dmg
DmgOptions - macOS DMG options.pkg
PkgOptions - macOS PKG options.
win
WindowsConfiguration - Options related to how build Windows targets.nsis
NsisOptionsnsisWeb
NsisWebOptions | “undefined”portable
PortableOptions | “undefined”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.flatpak
FlatpakOptions - Flatpak options.pacman
LinuxTargetSpecificOptionsrpm
LinuxTargetSpecificOptionsfreebsd
LinuxTargetSpecificOptionsp5p
LinuxTargetSpecificOptionsapk
LinuxTargetSpecificOptionsincludeSubNodeModules
=false
Boolean - Whether to include all of the submodules node_modules directories
-
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 use npm (neither
.npmrc
) for configuring electron headers. Useelectron-builder node-gyp-rebuild
instead. -
npmArgs
Array<String> | String | “undefined” - 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. -
nativeRebuilder
=sequential
“legacy” | “sequential” | “parallel” | “undefined” - Uselegacy
app-builder binary for installing native dependencies, or@electron/rebuild
insequential
orparallel
compilation modes. -
buildNumber
String | “undefined” - The build number. Maps to the--iteration
flag for builds using FPM on Linux. If not defined, then it will fallback toBUILD_NUMBER
orTRAVIS_BUILD_NUMBER
orAPPVEYOR_BUILD_NUMBER
orCIRCLE_BUILD_NUM
orBUILD_BUILDNUMBER
orCI_PIPELINE_IID
env.
-
buildVersion
String | “undefined” - The build version. Maps to theCFBundleVersion
on macOS, andFileVersion
metadata property on Windows. Defaults to theversion
. IfbuildVersion
is not defined andbuildNumber
(or one of thebuildNumber
envs) is defined, it will be used as a build version (version.buildNumber
). -
downloadAlternateFFmpeg
Boolean - Whether to download the alternate FFmpeg library from Electron’s release assets and replace the default FFmpeg library prior to signing -
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 | module:app-builder-lib/out/configuration.__type - Returns the path to custom Electron build (e.g.~/electron/out/R
). Zip files must follow the patternelectron-v${version}-${platformName}-${arch}.zip
, otherwise it will be assumed to be an unpacked Electron app directory -
electronDownload
- The electron-download options.version
Stringcache
String | “undefined” - The cache location.mirror
String | “undefined” - The mirror.strictSSL
BooleanisVerifyChecksum
Booleanplatform
“darwin” | “linux” | “win32” | “mas”arch
String
-
electronBranding
ElectronBrandingOptions - The branding used by Electron’s distributables. This is needed if a fork has modified Electron’s BRANDING.json file. -
electronVersion
String | “undefined” - The version of electron you are packaging for. Defaults to version ofelectron
,electron-prebuilt
orelectron-prebuilt-compile
dependency. -
extends
Array<String> | String | “undefined” - The name of a built-in configuration preset (currently, onlyreact-cra
is supported) or any number of paths to config files (relative to project dir).The latter allows to mixin a config from multiple other configs, as if you
Object.assign
them, but properly combinefiles
glob patterns.If
react-scripts
in the app 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).nodeVersion
String | “undefined” - libui-based frameworks only The version of NodeJS you are packaging for. You can set it tocurrent
to set the Node.js version that you use to run.launchUiVersion
Boolean | String | “undefined” - libui-based frameworks only The version of LaunchUI you are packaging for. Applicable for Windows only. Defaults to version suitable for used framework version.framework
String | “undefined” - The framework name. One ofelectron
,proton
,libui
. Defaults toelectron
.beforePack
module:app-builder-lib/out/configuration.__type | String | “undefined” - The function (or path to file or module id) to be run before packafterExtract
module:app-builder-lib/out/configuration.__type | String | “undefined” - The function (or path to file or module id) to be run after the prebuilt Electron binary has been extracted to the output directory
-
afterPack
- The function (or path to file or module id) to be run after pack (but before pack into distributable format and sign). -
afterSign
- The function (or path to file or module id) to be run after pack and sign (but before pack into distributable format). -
artifactBuildStarted
module:app-builder-lib/out/configuration.__type | String | “undefined” - The function (or path to file or module id) to be run on artifact build start. -
artifactBuildCompleted
module:app-builder-lib/out/configuration.__type | String | “undefined” - The function (or path to file or module id) to be run on artifact build completed. -
afterAllArtifactBuild
- The function (or path to file or module id) to be run after all artifacts are build. -
msiProjectCreated
module:app-builder-lib/out/configuration.__type | String | “undefined” - MSI project created on disk - not packed into .msi package yet. -
appxManifestCreated
module:app-builder-lib/out/configuration.__type | String | “undefined” - Appx manifest created on disk - not packed into .appx package yet. -
onNodeModuleFile
- The function (or path to file or module id) to be run on each node module file. Returningtrue
/false
will determine whether to force include or to use the default copier logic -
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.If provided and
node_modules
are missing, it will not invoke production dependencies check. -
includePdb
=false
Boolean - Whether to include PDB files. -
removePackageScripts
=true
Boolean - Whether to removescripts
field frompackage.json
files. -
removePackageKeywords
=true
Boolean - Whether to removekeywords
field frompackage.json
files. -
disableSanityCheckAsar
=false
Boolean - Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)
Overridable per Platform Options¶
Following options can be set also per platform (top-level keys mac, linux and win) if need.
-
appId
=com.electron.${name}
String | “undefined” - 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. -
artifactName
String | “undefined” - The artifact file name template. Defaults to${productName}-${version}.${ext}
(some target can have other defaults, see corresponding options). -
executableName
String | “undefined” - The executable name. Defaults toproductName
. -
compression
=normal
“store” | “normal” | “maximum” | “undefined” - The compression level. If you want to rapidly test build,store
can reduce build time significantly.maximum
doesn’t lead to noticeable size difference, but increase build time. -
disableDefaultIgnoredFiles
=false
Boolean | “undefined” - Whether to exclude all default ignored files(https://www.electron.build/configuration/contents#files) and options. Defaults tofalse
. -
files
The files configuration. -
extraResources
The extra resources configuration. -
extraFiles
The extra files configuration. -
asar
=true
AsarOptions | Boolean | “undefined” - Whether to package the application’s source code into an archive, using Electron’s archive format.Node modules, that must be unpacked, will be detected automatically, you don’t need to explicitly set asarUnpack - please file an issue if this doesn’t work.
-
asarUnpack
Array<String> | String | “undefined” - A glob patterns relative to the app directory, which specifies which files to unpack when creating the asar archive.
fileAssociations
Array<FileAssociation> | FileAssociation - The file associations.-
ext
String | Array<String> - The extension (minus the leading period). e.g.png
. -
name
String | “undefined” - The name. e.g.PNG
. Defaults toext
. -
description
String | “undefined” - windows-only. The description. -
mimeType
String | “undefined” - linux-only. The mime-type. -
icon
String | “undefined” - The path to icon (.icns
for MacOS and.ico
for Windows), relative tobuild
(build resources directory). Defaults to${firstExt}.icns
/${firstExt}.ico
(if several extensions specified, first is used) or to application icon.Not supported on Linux, file issue if need (default icon will be
x-office-document
). Not supported on MSI. -
role
=Editor
String - macOS-only The app’s role with respect to the type. The value can beEditor
,Viewer
,Shell
, orNone
. Corresponds toCFBundleTypeRole
. -
isPackage
Boolean - macOS-only Whether the document is distributed as a bundle. If set to true, the bundle directory is treated as a file. Corresponds toLSTypeIsPackage
. -
rank
=Default
String - macOS-only The app’s rank with respect to the type. The value can beOwner
,Default
,Alternate
, orNone
. Corresponds toLSHandlerRank
.
-
protocols
Array<Protocol> | Protocol - The URL protocol schemes.name
String - The name. e.g.IRC server URL
.schemes
Array<String> - The schemes. e.g.["irc", "ircs"]
.role
=Editor
“Editor” | “Viewer” | “Shell” | “None” - macOS-only The app’s role with respect to the type.
electronLanguages
Array<String> | String - The electron locales to keep. By default, all Electron locales used as-is.
-
forceCodeSigning
Boolean - Whether to fail if app will be not code signed. -
electronUpdaterCompatibility
String | “undefined” - The electron-updater compatibility semver range. -
publish
The publish options. -
detectUpdateChannel
=true
Boolean - Whether to infer update channel from application version pre-release components. e.g. if version0.12.1-alpha.1
, channel will be set toalpha
. Otherwise tolatest
. -
generateUpdatesFilesForAllChannels
=false
Boolean - Please see Building and Releasing using Channels. -
releaseInfo
- The release info. Intended for command line usage:-c.releaseInfo.releaseNotes="new features"
releaseName
String | “undefined” - The release name.releaseNotes
String | “undefined” - The release notes.releaseNotesFile
String | “undefined” - The path to release notes file. Defaults torelease-notes-${platform}.md
(whereplatform
it is current platform —mac
,linux
orwindows
) orrelease-notes.md
in the build resources.releaseDate
String - The release date.vendor
Object<String, any> | “undefined” - Vendor specific information.
-
target
String | TargetConfiguration -
defaultArch
String
Metadata¶
Some standard fields should be defined in the package.json
.
-
name
String - The application name. -
description
String - The application description. -
homepage
String | “undefined” - The url to the project homepage (NuGet PackageprojectUrl
(optional) or Linux Package URL (required)).If not specified and your project repository is public on GitHub, it will be
https://github.com/${user}/${project}
by default. -
license
String | “undefined” - linux-only. The license name. -
author
AuthorMetadata | “undefined” -
repository
String | RepositoryInfo | “undefined” - The repository. -
build
Configuration - The electron-builder configuration.
Proton Native¶
To package Proton Native app, set protonNodeVersion
option to current
or specific NodeJS version that you are packaging for.
Currently, only macOS and Linux supported.
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).
Hooks¶
Node.js 8
All examples assumed that you use latest Node.js 8.11.x or higher.
beforePack¶
The function (or path to file or module id) to be run before pack.
(context: BeforePackContext): Promise<any> | any
As function
beforePack: async (context) => {
// your code
}
Because in a configuration file you cannot use JavaScript, can be specified as a path to file or module id. Function must be exported as default export.
"build": {
"beforePack": "./myBeforePackHook.js"
}
File myBeforePackHook.js
in the project root directory:
myBeforePackHook.js
exports.default = async function(context) {
// your custom code
}
afterPack¶
The function (or path to file or module id) to be run after pack (but before pack into distributable format and sign).
(context: AfterPackContext): Promise<any> | any
As function
afterPack: async (context) => {
// your code
}
Because in a configuration file you cannot use JavaScript, can be specified as a path to file or module id. Function must be exported as default export.
"build": {
"afterPack": "./myAfterPackHook.js"
}
File myAfterPackHook.js
in the project root directory:
myAfterPackHook.js
exports.default = async function(context) {
// your custom code
}
afterSign¶
The function (or path to file or module id) to be run after pack and sign (but before pack into distributable format).
(context: AfterPackContext): Promise<any> | any
Configuration in the same way as afterPack
(see above).
afterAllArtifactBuild¶
The function (or path to file or module id) to be run after all artifacts are built.
(buildResult: BuildResult): Promise<Array<string>> | Array<string>
Configuration in the same way as afterPack
(see above).
myAfterAllArtifactBuild.js
exports.default = function () {
// you can return additional files to publish
return ["/path/to/additional/result/file"]
}
onNodeModuleFile¶
The function (or path to file or module id) to be run on each node module file.
(file: string) => void
Configuration in the same way as afterPack
(see above).
AfterPackContext¶
interface AfterPackContext {
outDir: string
appOutDir: string
packager: PlatformPackager<any>
electronPlatformName: string
arch: Arch
targets: Array<Target>
}
BuildResult¶
interface BuildResult {
outDir: string
artifactPaths: Array<string>
platformToTargets: Map<Platform, Map<string, Target>>
configuration: Configuration
}