Skip to main content
electron-builder packages your application code and resources into distributable formats. Understanding how files are organized and what gets included is crucial for optimizing your app’s size and performance.

Default File Inclusion

By default, electron-builder includes:
  • Your application code (from the app directory)
  • node_modules dependencies
  • package.json
  • All required runtime files
The default behavior automatically excludes development dependencies, test files, and common non-runtime files.

ASAR Archives

What is ASAR?

ASAR (Atom Shell Archive) is a simple archive format that concatenates files into a single file. Electron can read files from ASAR archives without unpacking them, which provides:
  • Faster loading: Single file reads are faster than many small file reads
  • Reduced file count: Improves performance on Windows
  • Basic obfuscation: Source code is not immediately visible (but not encrypted)

Default ASAR Configuration

By default, your application code is packaged into app.asar:
package.json

ASAR Integrity Validation

electron-builder supports ASAR integrity validation to prevent tampering:
package.json
ASAR integrity checking is supported on:
  • macOS as of Electron 16.0.0+
  • Windows as of Electron 30.0.0+
When enabling onlyLoadAppFromAsar, Electron will only load code from app.asar, not from unpacked app directories. Combine this with integrity validation for maximum security.

Unpacking Files from ASAR

Some files need to be unpacked from ASAR:
  • Native Node.js addons (.node files)
  • Files accessed by external processes
  • Files that need to be executable
package.json
electron-builder automatically unpacks .node files by default. You only need to explicitly specify asarUnpack for special cases.

Disabling ASAR

For development or specific use cases, you can disable ASAR:
Disabling ASAR increases the number of files in your package, which can slow down application startup, especially on Windows.

File Configuration Options

files

Specifies which files to include in the application:
package.json
See File Patterns for detailed information on glob pattern syntax.

extraResources

Files to copy to the app’s resources directory (outside ASAR):
package.json
Location in packaged app:
  • macOS: Contents/Resources/
  • Windows: resources/
  • Linux: resources/
Accessing in code:

extraFiles

Files to copy to the app’s output directory (outside ASAR and resources):
package.json
Location in packaged app:
  • macOS: Contents/ (app contents root)
  • Windows: App directory root
  • Linux: App directory root

FileSet Configuration

Both extraResources and extraFiles support FileSet configuration:
FileSet interface:

Application Directory Structure

Packaged App Structure

Optimizing Application Size

1. Remove Unnecessary Dependencies

Move development dependencies to devDependencies:
package.json

2. Exclude Development Files

3. Use Compression

Compression levels: store (no compression), normal (default), maximum

4. Remove Metadata

Accessing Packaged Resources

From Main Process

main.js

From Renderer Process

renderer.js

Build Hooks for File Processing

Use hooks to process files during the build:
electron-builder.config.js
See the Build Configuration page for more information on build hooks.

Development vs Production

Development Configuration

Production Configuration