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
module.exports = {
  packagerConfig: {},
  makers: [
    {
      name: '@electron-forge/maker-zip'
    }
  ]
};

We recommend using JavaScript for your config file since it enables conditional logic within your configuration.

Configuration options

module.exports = {
  packagerConfig: { /* ... */ },
  rebuildConfig: { /* ... */ },
  makers: [],
  publishers: [],
  plugins: [],
  hooks: { /* ... */ },
  buildIdentifier: 'my-build'
};

All properties are optional

Electron Packager config

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.

The options you can put in this object are documented in the Electron Packager API docs.

You can not override the dir, arch, platform, out or electronVersion options as they are set by Electron Forge internally.

Electron Rebuild config

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.

The options you can put in this object are documented in the Electron Rebuild API docs.

You can not override the buildPath, arch, or electronVersion options as they are set by Electron Forge internally

Makers

The 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.

Publishers

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.

Plugins

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.

Hooks

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.

Check out the Hooks documentation for all possible hooks and their config options.

Build identifiers

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 updated