CLI
How to use the command line interface (CLI) commands for Electron Forge
Overview
Forge's CLI is the main way to run Electron Forge commands. It consists of a thin wrapper for its core API. Configuration for these commands is done through your Forge configuration object.
If you want to use the core API programmatically, see the Programmatic usage section below.
Forge's CLI uses comma-separated value strings to pass multiple arguments into a single flag. Depending on your terminal, these comma-separated values may need to be enclosed in quotation marks.
Installation
To use the Forge CLI, install the @electron-forge/cli
module into your project as a devDependency. If you're using the create-electron-app
script, this module will already be installed for you.
Bootstrap commands
These commands help you get started with Forge. If you're just getting started with Electron Forge, we recommend you follow the Getting Started or Importing an Existing Project guides.
Init
We recommend using the create-electron-app
script (which uses this command) to get started rather than running Init directly.
This command will initialize a new Forge-powered application in the given directory (defaults to .
, the current directory).
Please note if you want to use a non-builtin template, it must be installed globally before running the init
command.
Options
All flags are optional.
Usage
Import
This command will attempt to take an existing Electron app and make it compatible with Forge. Normally, this just creates a base Electron Forge configuration and adds the required dependencies.
Options
There are no options for the Import command.
Usage
Build commands
The Package, Make, and Publish commands are the three main steps of the Electron Forge build pipeline. Each step relies on the output of the previous one, so they are cascading by default (e.g. running publish
will first run package
then make
.
For more conceptual details, see the Build Lifecycle guide.
Package
This command will package your application into a platform-specific executable bundle and put the result in a folder. Please note that this does not make a distributable format. To make proper distributables, please use the Make command.
Options
All flags are optional.
Usage
Make
This command will make distributables for your application based on your Forge config and the parameters you pass in.
If you do not need to repackage your application between Make runs, use the --skip-package
flag.
Options
All flags are optional.
Usage
Basic usage:
Building for ia32 and x64 architectures:
Publish
This command will attempt to package, make, and publish the Forge application to the publish targets defined in your Forge config.
If you want to verify artifacts from the Make step before publishing, you can use the Dry Run options explained below.
Options
All flags are optional.
Usage
Dev commands
Start
This command will launch your app in dev mode with the electron
binary in the given directory (defaults to .
).
If you type rs
(and hit enter) in the same terminal where you ran the start command, the running app will be terminated and restarted.
Forge plugins can override this command to run custom development logic. For example, the Webpack Plugin runs a webpack-dev-server instance to provide live reloading and HMR.
Options
All flags are optional.
Usage
Programmatic usage
The Forge CLI should suit most use cases, but we do expose the @electron-forge/core
package for programmatic command usage.
For more information, see the API documentation.
Last updated