Comment on page
Overview
How to configure Electron Forge
Electron Forge configuration is centralized in a single configuration object. You can specify this config in your package.json on the
config.forge
property. This property can have be in one of two forms:- An object containing your entire Forge configuration.
- A relative path pointing at a JavaScript file that exports your config.
If you do not have
config.forge
set in your package.json file, Forge will attempt to find a forge.config.js
file in your project root.forge.config.js
package.json
forge.config.js
module.exports = {
packagerConfig: {},
makers: [
{
name: '@electron-forge/maker-zip'
}
]
};
package.json
{
"name": "my-app",
"version": "0.0.1",
"config": {
"forge": {
"packagerConfig": {},
"makers": [
{
"name": "@electron-forge/maker-zip"
}
]
}
}
}
We recommend using JavaScript for your config file since it enables conditional logic within your configuration.
forge.config.js
package.json
module.exports = {
packagerConfig: { /* ... */ },
rebuildConfig: { /* ... */ },
makers: [],
publishers: [],
plugins: [],
hooks: { /* ... */ },
buildIdentifier: 'my-build'
};
// Only the relevant section of package.json is shown, for brevity.
{
"config": {
"forge": {
"packagerConfig": { ... },
"rebuildConfig": { ... },
"makers": [ ... ],
"publishers": [ ... ],
"plugins": [ ... ],
"hooks": { ... },
"buildIdentifier": "my-build"
}
}
}
All properties are optional
The top level property
packagerConfig
on the configuration object maps directly to the options sent to electron-packager
during the package step of Electron Forge's build process.You can not override the
dir
, arch
, platform, out
or electronVersion
options as they are set by Electron Forge internally.The top level property
rebuildConfig
on the configuration object maps directly to the options sent to electron-rebuild
during both the package and start step of Electron Forge's build process.You can not override the
buildPath
, arch
, or electronVersion
options as they are set by Electron Forge internallyThe top level property
makers
on the configuration object is an array of maker configurations. Check out the Makers documentation for all possible makers and their config options.The top level property
publishers
on the configuration object is an array of publisher configurations. Check out the Publishers documentation for all possible publishers and their config options.The top level property
plugins
on the configuration object is an array of plugin configurations. Check out the Plugins documentation for all possible plugins and their config options.The top level property
hooks
on the configuration object is an object containing hooks that can be used to insert custom logic during the build lifecycle.This property can be used to identify different build configurations. Normally, this property is set to the channel the build will release to, or some other unique identifier. For example, common values are
prod
and beta
. This identifier can be used in conjunction with the fromBuildIdentifier
function to generate release channel or environment specific configuration. For example:forge.config.js
const { utils: { fromBuildIdentifier } } = require('@electron-forge/core');
module.exports = {
buildIdentifier: process.env.IS_BETA ? 'beta' : 'prod',
packagerConfig: {
appBundleId: fromBuildIdentifier({ beta: 'com.beta.app', prod: 'com.app' })
}
};
In this example the
appBundleId
option passed to Electron Packager will be selected based on the buildIdentifer
based on whether you are building for prod
or beta
. This allows you to make shared configs incredibly easily as only the values that change need to be wrapped with this function.Last modified 20d ago