Skip to main content

File Patterns

  • * Matches 0 or more characters in a single path portion
  • ? Matches 1 character
  • [...] Matches a range of characters, similar to a RegExp range. If the first character of the range is ! or ^ then it matches any character not in the range.
  • !(pattern|pattern|pattern) Matches anything that does not match any of the patterns provided.
  • ?(pattern|pattern|pattern) Matches zero or one occurrence of the patterns provided.
  • +(pattern|pattern|pattern) Matches one or more occurrences of the patterns provided.
  • *(a|b|c) Matches zero or more occurrences of the patterns provided
  • @(pattern|pat*|pat?erN) Matches exactly one of the patterns provided
  • ** If a "globstar" is alone in a path portion, then it matches zero or more directories and subdirectories searching for matches. It does not crawl symlinked directories.

If directory matched, all contents are copied. So, you can just specify foo to copy foo directory.

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${/*}.

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",
]

Default Ignored Files

electron-builder excludes a set of files from the packaged app by default (development files, and certain extensions/names such as Wavefront .obj 3D models). In v27 the disableDefaultIgnoredFiles option was removed. To keep a file that is excluded by default, add an explicit files glob that names it concretely — an explicit include now overrides the matching default exclusion:

{
"build": {
"files": [
"**/*",
"**/*.obj" // opt a default-excluded extension back in
]
}
}

Broad patterns such as **/* still honor the defaults; only a pattern that names the extension or directory concretely opts it back in. See v27 Breaking Changes → disableDefaultIgnoredFiles.

File Macros

You can use macros in the file patterns, artifact file name patterns and publish configuration url:

  • ${arch} — expanded to ia32, x64. If no arch, macro will be removed from your pattern with leading space, - and _ (so, you don't need to worry and can reuse pattern).
  • ${os} — expanded to mac, linux or win according to target platform.
  • ${platform} — expanded to darwin, linux or win32 according to Node.js process.platform property.
  • ${name}package.json name.
  • ${productName}Sanitized product name.
  • ${version}
  • ${channel} — detected prerelease component from version (e.g. beta).
  • ${env.ENV_NAME} — any environment variable.
  • Any property of AppInfo (e.g. buildVersion, buildNumber).