Skip to content

Electron

Overview

Warning

Electron support is in beta, so you may encounter problems and missing features. It has only been tested with recent Electron versions. Please let us know in the discussion forum or chat rooms how you get along.

When using Conveyor to package Electron apps the results differ slightly from other tools. There are several update engines that can be used with Electron, however they all have a variety of problems:

Conveyor uses platform native updates or Sparkle 2 on macOS, and regular HTTP servers.

The other standard features of Conveyor can also save a lot of time and hassle:

  • No need to find machines for each target OS to build packages. You can make packages for every OS on your laptop.
  • Use more convenient config syntax and features than raw JSON.
  • Handles all the details of code signing without native tools, which are often awkward to use.
  • Can self-sign if you don't want to use signing keys. Other tools make unsigned apps if you don't have keys, but these don't integrate with the host operating system as well.
  • You get a self-contained download site with HTML that detects your users operating system and CPU.
  • It's fully documented. Other Electron packaging tools sometimes point you to doc pages that don't document the config keys.

Conveyor treats Electron apps mostly the same as native apps, meaning that no code changes are necessary to get working software updates.

Synopsis

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
// You must import the electron stdlib config, otherwise things won't work properly.
include required("/stdlib/electron/electron.conf")

// You must also import your package-lock.json file because the defaults will be set based on it.
package-lock {
    include required("package-lock.json") 
}

// Override the Electron version intead of using the version in your package.json file. 
app.electron.version = 19.0.1

// Change where it's downloaded from. The default is GitHub:
app.electron.download-base-url = github.com/electron/electron/releases/download/ 

Keys

app.electron.version If set then this config is for an Electron app, and this is the version of Electron to bundle.

app.electron.download-base-url Where to find Electron builds to download. The URLs are composed like this:

1
${app.electron.download-base-url}/v${app.electron.version}/electron-v${app.electron.version}-$os-$cpu.zip

so they must follow the same lahyout as that used on GitHub. You can specify a file: URL here if necessary.

App resources

The contents of your base inputs will be copied to the resources/app directory. Thus, you should import at least a package.json, an index.html and so on as inputs. You should also import your node_modules directory to the same location. Inputs are by default always placed at the top level so you need to specify the destination explicitly. A simple example is like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
app {
  inputs = ${app.inputs} [
    "*.{json,js,css,html}"

    {
      from = node_modules
      to = node_modules
      remap = [ "-electron/dist/**" ]
    }
  ]
}

It's important to drop the dist directory of the electron module because it contains a copy of the Electron Mac app, but that will interfere with notarization and isn't necessary. You can exclude other kinds of files from your node_modules here too. See the inputs section for more information on remap specs and the input syntax used above.

Caveats

Support for Electron is in beta. Be aware of the following caveats:

  • There's no API to control or monitor updates. Note that such an API doesn't necessarily make sense on some platforms e.g. Linux where the user's package manager will apply updates, or on Windows where the app can be updated silently in the background when it's not running.
  • It has only been tested with Electron 19 and 20.
  • Conveyor doesn't yet make ASAR files, so all files will be shipped unpacked. If your app consists of very large numbers of small files this may reduce performance. You can make an asar file yourself and supply it as an input to work around this limitation.
  • You can't run any code during installation/uninstallation on Windows or macOS (only on Linux and only when using native packages).