Electron Forge
The simple way to get started with Electron
Getting Started
npm install -g electron-forge
electron-forge init my-new-app
cd my-new-app
electron-forge start
Urgh, really... Another build tool
Funnily enough, no :D. This is not another build tool, electron-forge
simply
unifies the existing (and well maintained) build tools for Electron development
into one, simple, easy to use package so that anyone can just jump right in
to Electron development.
So what's the point
This project has a few main goals.
- Starting with Electron should be as simple as a single command
- Developers shouldn't have to worry about
babel
, browserify
, webpack
or
any of that nonsense. Everything should just work for them out of the box. - Everything from creating the project to packaging the project for release
should be handled by one dependency in a standard way while still offering users
maximum choice and freedom.
With these goals in mind, under the hood this project uses
electron-compile
: a tool
that lets you use modern and futuristic langauges inside Electron without
worrying about transpiling or build tooling.
So go on then... How do I use the thing :)
Glad you asked, it's beyond easy to get started with electron-forge
.
Starting a new Project
npm install -g electron-forge
electron-forge init my-new-project
This command will generate you a brand new project folder and install all your NPM dependencies so you will be all set to go. By default we will also install airbnb
linting modules. If you want to follow the standard
linting rules instead use the --lintstyle=standard
argument.
Launching your Project
electron-forge start
Any args after "start" will be passed through to your application when it is launched.
Packaging your Project
electron-forge package
Yes, it really is that simple. If you want to specify platform / arch, use the
--platform=<platform>
and --arch=<arch>
arguments.
Generating a distributable for your Project
electron-forge make
This will generate platform specific distributables for you. Note you can only generate distributables for your current platform.
Linting your Project
electron-forge lint
Config
Once you have generated a project your package.json
file will have some default forge
config. Below is the reference structure for this config object.
{
"make_targets": {
"win32": ["squirrel"],
"darwin": ["zip", "dmg"],
"linux": ["deb", "rpm", "flatpak"]
},
"electronPackagerConfig": {},
"electronWinstallerConfig": {},
"electronInstallerDMG": {},
"electronInstallerFlatpak": {},
"electronInstallerDebian": {},
"electronInstallerRedhat": {}
}
Possible make
targets
Configuring package
You can set electronPackagerConfig
with any of the options from Electron Packager.
NOTE: The afterCopy
and afterExtract
are mapped to require
calls internally so provide a path to a file that exports your hooks and they will still run.