Default File Inclusion
By default, electron-builder includes:- Your application code (from the app directory)
node_modulesdependenciespackage.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 intoapp.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+
Unpacking Files from ASAR
Some files need to be unpacked from ASAR:- Native Node.js addons (
.nodefiles) - 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: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
- macOS:
Contents/Resources/ - Windows:
resources/ - Linux:
resources/
extraFiles
Files to copy to the app’s output directory (outside ASAR and resources):package.json
- macOS:
Contents/(app contents root) - Windows: App directory root
- Linux: App directory root
FileSet Configuration
BothextraResources and extraFiles support FileSet configuration:
Application Directory Structure
Packaged App Structure
- macOS
- Windows
- Linux
Optimizing Application Size
1. Remove Unnecessary Dependencies
Move development dependencies todevDependencies:
package.json
2. Exclude Development Files
3. Use Compression
Compression levels:
store (no compression), normal (default), maximum4. 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.