Skip to content
develar edited this page Sep 20, 2016 · 77 revisions

Options

In the development package.json custom build field can be specified to customize format:

"build": {
  "dmg": {
    "contents": [
      {
        "x": 410,
        "y": 220,
        "type": "link",
        "path": "/Applications"
      },
      {
        "x": 130,
        "y": 220,
        "type": "file",
        "path": "computed path to artifact, do not specify it - will be overwritten"
      }
    ]
  }
}

As you can see, you need to customize MacOS options only if you want to provide custom x, y. Don't customize paths to background and icon, — just follow conventions.

Application package.json

Name Description
name The application name.
productName

As name, but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the name property.

description The application description.
homepage

The url to the project homepage (NuGet Package projectUrl (optional) or Linux Package URL (required)).

If not specified and your project repository is public on GitHub, it will be https://github.com/${user}/${project} by default.

license linux-only. The license name.

Development package.json

Name Description
build See .build.
directories See .directories

.build

Name Description
appId

The application id. Used as CFBundleIdentifier for MacOS and as Application User Model ID for Windows (NSIS target only, Squirrel.Windows not supported).

Defaults to com.electron.${name}. It is strongly recommended that an explicit ID be set.

copyright The human-readable copyright line for the app. Defaults to Copyright © year author.
asar

Whether to package the application’s source code into an archive, using Electron’s archive format. Defaults to true. Reasons why you may want to disable this feature are described in an application packaging tutorial in Electron’s documentation.

Or you can pass object of any asar options.

Node modules, that must be unpacked, will be detected automatically, you don’t need to explicitly set asar.unpackDir - please file issue if this doesn’t work.

productName See AppMetadata.productName.
files

A glob patterns relative to the app directory, which specifies which files to include when copying files to create the package.

See File Patterns.

extraResources

A glob patterns relative to the project directory, when specified, copy the file or directory with matching names directly into the app’s resources directory (Contents/Resources for MacOS, resources for Linux/Windows).

Glob rules the same as for files.

extraFiles The same as extraResources but copy into the app's content directory (Contents for MacOS, root directory for Linux/Windows).
fileAssociations The file associations. See .build.fileAssociations.
protocols The URL protocol scheme(s) to associate the app with. See .build.protocol.
mac See .build.mac.
dmg See .build.dmg.
mas See .build.mas.
win See .build.win.
nsis See .build.nsis.
linux See .build.linux.
compression The compression level, one of store, normal, maximum (default: normal). If you want to rapidly test build, store can reduce build time significantly.
afterPack programmatic API only The function to be run after pack (but before pack into distributable format and sign). Promise must be returned.
npmRebuild two package.json structure only Whether to rebuild native dependencies (npm rebuild) before starting to package the app. Defaults to true.
nodeGypRebuild Whether to execute node-gyp rebuild before starting to package the app. Defaults to false.
electronDist The path to custom Electron build (e.g. ~/electron/out/R). Only macOS supported, file issue if need for Linux or Windows.

.build.dmg

MacOS DMG specific options.

See all appdmg options.

Name Description
icon The path to DMG icon, which will be shown when mounted. Defaults to build/icon.icns.
background

The path to background (default: build/background.png if exists). The resolution of this file determines the resolution of the installer window. If background is not specified, use window.size, see specification.

.build.fileAssociations

NSIS and MacOS only.

Name Description
ext The extension (minus the leading period). e.g. png.
name The name. e.g. PNG.
description windows-only. The description.
icon The path to icon (.icns for MacOS and .ico for Windows), relative to build (build resources directory). Defaults to ${firstExt}.icns/${firstExt}.ico (if several extensions specified, first is used) or to application icon.
role macOS-only The app’s role with respect to the type. The value can be Editor, Viewer, Shell, or None. Defaults to Editor.

.build.linux

Linux specific build options.

Name Description
category The application category.
packageCategory The package category. Not applicable for AppImage.
description As description from application package.json, but allows you to specify different for Linux.
target

Target package type: list of AppImage, deb, rpm, freebsd, pacman, p5p, apk, 7z, zip, tar.xz, tar.lz, tar.gz, tar.bz2. Defaults to AppImage.

The most effective xz compression format used by default.

Only deb and AppImage is tested. Feel free to file issues for rpm and other package formats.

synopsis deb-only. The short description.
maintainer The maintainer. Defaults to author.
vendor The vendor. Defaults to author.
desktop The Desktop file entries.
compression deb-only. The compression type, one of gz, bzip2, xz. Defaults to xz.
depends Package dependencies. Defaults to ["libappindicator1", "libnotify-bin"].

.build.mac

MacOS specific build options.

Name Description
category

The application category type, as shown in the Finder via View -> Arrange by Application Category when viewing the Applications directory.

For example, "category": "public.app-category.developer-tools" will set the application category to Developer Tools.

Valid values are listed in Apple’s documentation.

target Target package type: list of default, dmg, mas, 7z, zip, tar.xz, tar.lz, tar.gz, tar.bz2. Defaults to default (dmg and zip for Squirrel.Mac).
identity

The name of certificate to use when signing. Consider using environment variables CSC_LINK or CSC_NAME. MAS installer identity is specified in the .build.mas.

icon The path to application icon. Defaults to build/icon.icns (consider using this convention instead of complicating your configuration).
entitlements

The path to entitlements file for signing the app. build/entitlements.mac.plist will be used if exists (it is a recommended way to set). MAS entitlements is specified in the .build.mas.

entitlementsInherit

The path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution. build/entitlements.mac.inherit.plist will be used if exists (it is a recommended way to set). Otherwise default.

This option only applies when signing with entitlements provided.

bundleVersion The CFBundleVersion. Do not use it unless you need to.
helperBundleId The bundle identifier to use in the application helper's plist. Defaults to ${appBundleIdentifier}.helper.

.build.mas

MAS (Mac Application Store) specific options (in addition to build.mac).

Name Description
entitlements

The path to entitlements file for signing the app. build/entitlements.mas.plist will be used if exists (it is a recommended way to set). Otherwise default.

entitlementsInherit

The path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution. build/entitlements.mas.inherit.plist will be used if exists (it is a recommended way to set). Otherwise default.

.build.nsis

See NSIS target notes.

Name Description
oneClick One-click installation. Defaults to true.
perMachine

Defaults to false.

If oneClick is true (default): Install per all users (per-machine).

If oneClick is false: no install mode installer page (choice per-machine or per-user), always install per-machine.

allowElevation boring installer only. Allow requesting for elevation. If false, user will have to restart installer with elevated permissions. Defaults to true.
runAfterFinish one-click installer only. Run application after finish. Defaults to true.
guid See GUID vs Application Name.
installerHeader boring installer only. MUI_HEADERIMAGE, relative to the project directory. Defaults to build/installerHeader.bmp
installerHeaderIcon one-click installer only. The path to header icon (above the progress bar), relative to the project directory. Defaults to build/installerHeaderIcon.ico or application icon.
include The path to NSIS include script to customize installer. Defaults to build/installer.nsh. See Custom NSIS script.
script The path to NSIS script to customize installer. Defaults to build/installer.nsi. See Custom NSIS script.
language * LCID Dec, defaults to 1033(English - United States).

.build.protocols

macOS only.

Name Description
name The name. e.g. IRC server URL.
role macOS-only The app’s role with respect to the type. The value can be Editor, Viewer, Shell, or None. Defaults to Editor.
schemes The schemes. e.g. ["irc", "ircs"].

.build.win

Windows specific build options.

Name Description
target Target package type: list of squirrel, nsis, 7z, zip, tar.xz, tar.lz, tar.gz, tar.bz2. Defaults to squirrel.
iconUrl

Squirrel.Windows-only. A URL to an ICO file to use as the application icon (displayed in Control Panel > Programs and Features). Defaults to the Electron icon.

Please note — local icon file url is not accepted, must be https/http.

loadingGif

Squirrel.Windows-only. The path to a .gif file to display during install. build/install-spinner.gif will be used if exists (it is a recommended way to set) (otherwise default).

msi Squirrel.Windows-only. Whether to create an MSI installer. Defaults to false (MSI is not created).
remoteReleases Squirrel.Windows-only. A URL to your existing updates. Or true to automatically set to your GitHub repository. If given, these will be downloaded to create delta updates.
remoteToken Squirrel.Windows-only. Authentication token for remote updates
signingHashAlgorithms Array of signing algorithms used. Defaults to ['sha1', 'sha256']
icon The path to application icon. Defaults to build/icon.ico (consider using this convention instead of complicating your configuration).
legalTrademarks The trademarks and registered trademarks.
certificateSubjectName The name of the subject of the signing certificate. Required only for EV Code Signing and works only on Windows.
rfc3161TimeStampServer The URL of the RFC 3161 time stamp server. Defaults to http://timestamp.comodoca.com/rfc3161.

.directories

Name Description
buildResources The path to build resources, defaults to build.
output The output directory, defaults to dist.
app The application directory (containing the application package.json), defaults to app, www or working directory.

File Patterns

build.files defaults to:

  • **/*
  • !**/node_modules/*/{README.md,README,readme.md,readme,test}
  • !**/node_modules/.bin
  • !**/*.{o,hprof,orig,pyc,pyo,rbc}
  • !**/{.DS_Store,.git,.hg,.svn,CVS,RCS,SCCS,__pycache__,thumbs.db}

Hidden files are not ignored by default, but as you see, all files that should be ignored, are ignored by default.

Development dependencies are never copied in any case. You don't need to ignore it explicitly.

Multiple patterns are supported. You can use ${os} (expanded to mac, linux or win according to current platform) and ${arch} in the pattern. If directory matched, all contents are copied. So, you can just specify foo to copy foo directory.

Remember that default pattern **/* is not added to your custom, so, you have to add it explicitly — e.g. ["**/*", "!ignoreMe${/*}"].

May be specified in the platform options (e.g. in the build.mac).

Multiple Glob Patterns

[
  // match all files
  "**/*",

  // except for js files in the foo/ directory
  "!foo/*.js",

  // unless it's foo/bar.js
  "foo/bar.js",
]

Excluding directories

Remember that !doNotCopyMe/**/* would match the files in the doNotCopyMe directory, but not the directory itself, so the empty directory would be created. Solution — use macro ${/*}, e.g. !doNotCopyMe${/*}.

Source and Destination Directories

You may also specify custom source and destination directories by using JSON objects instead of simple glob patterns. Note this only works for extraFiles and extraResources.

[
  {
    "from": "path/to/source",
    "to": "path/to/destination",
    "filter": ["**/*", "!foo/*.js"]
  }
]

If from is given as a relative path, it is relative to the project directory. If to is given as a relative path, it is relative to the app's content directory for extraFiles and the app's resource directory for extraResources.

You can you ${os} and ${arch} in the from and to fields as well.

Build Version Management

CFBundleVersion (MacOS) and FileVersion (Windows) will be set automatically to version.build_number on CI server (Travis, AppVeyor and CircleCI supported).