The top-level linux configuration contains options for building Linux targets. These options apply to all Linux target types including AppImage, Snap, Flatpak, deb, and rpm.
Linux Targets Overview
AppImage Universal Linux package format
Snap Snapcraft package for Ubuntu and more
Debian .deb packages for Debian-based systems
Base Linux Configuration
The linux key in your electron-builder configuration applies to all Linux targets:
{
"build" : {
"linux" : {
"target" : [ "AppImage" , "deb" , "snap" ],
"category" : "Utility" ,
"icon" : "build/icons" ,
"maintainer" : "Your Name <[email protected] >" ,
"vendor" : "Your Company" ,
"synopsis" : "Short description" ,
"description" : "Longer description of your application"
}
}
}
AppImage
AppImage is a universal Linux package format that runs on most Linux distributions without installation.
Basic AppImage Configuration
{
"build" : {
"appImage" : {
"license" : "LICENSE" ,
"category" : "Utility" ,
"synopsis" : "Short description of your app"
}
}
}
build :
appImage :
license : LICENSE
category : Utility
synopsis : Short description of your app
Desktop Integration
Since electron-builder 21, desktop integration is not included in the AppImage file. AppImageLauncher is the recommended way to integrate AppImages with your desktop environment.
AppImage Example
Build an AppImage with custom icon and desktop entry:
{
"build" : {
"linux" : {
"target" : "AppImage" ,
"category" : "Development" ,
"icon" : "build/icons"
},
"appImage" : {
"license" : "LICENSE" ,
"category" : "Development" ,
"desktop" : {
"StartupWMClass" : "my-app" ,
"MimeType" : "x-scheme-handler/myapp"
}
}
}
}
For complete AppImage configuration options, see the AppImageOptions interface reference.
Snap
Snap packages work across many Linux distributions and provide automatic updates.
Basic Snap Configuration
{
"build" : {
"snap" : {
"confinement" : "strict" ,
"grade" : "stable" ,
"summary" : "Short description for Snap store" ,
"plugs" : [
"default" ,
"home" ,
"network" ,
"pulseaudio"
]
}
}
}
build :
snap :
confinement : strict
grade : stable
summary : Short description for Snap store
plugs :
- default
- home
- network
- pulseaudio
Snap Confinement
Choose the appropriate confinement level:
strict - Full confinement with limited system access (recommended)
classic - No confinement, full system access (requires manual review)
devmode - Development mode with warnings instead of errors
Advanced Snap Configuration
{
"build" : {
"snap" : {
"confinement" : "strict" ,
"grade" : "stable" ,
"base" : "core20" ,
"plugs" : [
"default" ,
"home" ,
"network" ,
"network-bind" ,
"pulseaudio" ,
"x11" ,
"unity7" ,
"browser-support"
],
"slots" : [
"mpris"
],
"buildPackages" : [
"libsecret-1-dev"
],
"stagePackages" : [
"default" ,
"libsecret-1-0"
]
}
}
}
For complete Snap configuration options, see the SnapOptions interface reference.
Debian Package
Create .deb packages for Debian, Ubuntu, and other Debian-based distributions.
Basic Debian Configuration
{
"build" : {
"linux" : {
"target" : "deb"
},
"deb" : {
"depends" : [
"gconf2" ,
"gconf-service" ,
"libnotify4" ,
"libappindicator1"
],
"recommends" : [
"pulseaudio"
],
"afterInstall" : "build/deb-postinstall.sh" ,
"afterRemove" : "build/deb-prerm.sh"
}
}
}
build :
linux :
target : deb
deb :
depends :
- gconf2
- gconf-service
- libnotify4
- libappindicator1
recommends :
- pulseaudio
afterInstall : build/deb-postinstall.sh
afterRemove : build/deb-prerm.sh
Package Scripts
Create post-install and pre-remove scripts:
build/deb-postinstall.sh
#!/bin/bash
# Update desktop database
update-desktop-database /usr/share/applications
# Update mime database
update-mime-database /usr/share/mime
build/deb-prerm.sh
#!/bin/bash
# Cleanup before removal
echo "Removing application..."
Make sure scripts are executable: chmod +x build/*.sh
Debian Package Priorities
{
"build" : {
"deb" : {
"priority" : "optional" ,
"compression" : "xz"
}
}
}
Available priorities:
required - Essential for system operation
important - Important but not essential
standard - Standard system installations
optional - Optional packages (default)
extra - Conflicts with other packages
For complete Debian configuration options, see the DebOptions interface reference.
RPM Package
Create .rpm packages for Red Hat, Fedora, CentOS, and other RPM-based distributions.
Basic RPM Configuration
{
"build" : {
"linux" : {
"target" : "rpm"
},
"rpm" : {
"depends" : [
"libnotify" ,
"libappindicator"
],
"fpm" : [
"--rpm-rpmbuild-define" ,
"_build_id_links none"
],
"afterInstall" : "build/rpm-postinstall.sh" ,
"afterRemove" : "build/rpm-prerm.sh"
}
}
}
build :
linux :
target : rpm
rpm :
depends :
- libnotify
- libappindicator
fpm :
- --rpm-rpmbuild-define
- _build_id_links none
afterInstall : build/rpm-postinstall.sh
afterRemove : build/rpm-prerm.sh
RPM Package Groups
{
"build" : {
"rpm" : {
"packageCategory" : "Applications/Internet" ,
"license" : "MIT" ,
"vendor" : "Your Company"
}
}
}
Common package categories:
Applications/Internet
Applications/Development
Applications/Productivity
Applications/Multimedia
Applications/System
Other Linux Targets
electron-builder supports additional Linux package formats:
Flatpak {
"linux" : {
"target" : "flatpak"
}
}
Pacman {
"linux" : {
"target" : "pacman"
}
}
For Arch Linux and derivatives
APK {
"linux" : {
"target" : "apk"
}
}
For Alpine Linux
Target-Specific Configuration
Each target can have its own configuration:
{
"build" : {
"pacman" : {
"depends" : [ "libnotify" ],
"afterInstall" : "build/pacman-postinstall.sh"
},
"apk" : {
"depends" : [ "libnotify" ],
"maintainer" : "Your Name <[email protected] >"
}
}
}
Icon Requirements
Linux builds require icons in multiple sizes. Create a directory structure:
build/icons/
16x16.png
32x32.png
48x48.png
64x64.png
128x128.png
256x256.png
512x512.png
1024x1024.png
Or use a single 512x512 PNG icon:
{
"build" : {
"linux" : {
"icon" : "build/icon.png"
}
}
}
electron-builder will automatically generate the required icon sizes from a single 512x512 PNG file.
Building Multiple Targets
# Build specific targets
electron-builder --linux AppImage
electron-builder --linux deb
electron-builder --linux snap
# Build multiple targets
electron-builder --linux AppImage deb rpm
# Build all Linux targets
electron-builder --linux
# Specific targets
electron-builder --linux AppImage
electron-builder --linux deb
electron-builder --linux snap
# Multiple targets
electron-builder --linux AppImage deb snap
# All targets
electron-builder --linux
{
"build" : {
"linux" : {
"target" : [
"AppImage" ,
"deb" ,
"snap" ,
"rpm"
]
}
}
}
Desktop Entry
Customize the desktop entry for all Linux packages:
{
"build" : {
"linux" : {
"desktop" : {
"Name" : "My Application" ,
"GenericName" : "Application" ,
"Comment" : "Application description" ,
"Categories" : "Development;Utility;" ,
"MimeType" : "x-scheme-handler/myapp;" ,
"StartupWMClass" : "my-app" ,
"Terminal" : false ,
"Type" : "Application"
}
}
}
}
Common desktop entry categories:
Development - Development tools
Utility - Utility applications
Network - Network applications
Graphics - Graphics applications
AudioVideo - Multimedia applications
Office - Office applications