### Setup QEMU for Linux ARM Builds on x64 Source: https://www.electron.build/docs/architecture This one-time setup command installs QEMU support necessary for cross-compiling Linux ARM binaries on an x64 machine using Docker. ```bash # Install QEMU support (one-time setup) docker run --privileged --rm tonistiigi/binfmt --install arm64,arm ``` -------------------------------- ### Install Flatpak Runtimes Source: https://www.electron.build/docs/troubleshooting Flatpak builds may fail if the required runtimes are not installed. Install the platform and SDK runtimes. ```bash flatpak install flathub org.freedesktop.Platform//24.08 flatpak install flathub org.freedesktop.Sdk//24.08 ``` -------------------------------- ### Continuous Deployment setup with --publish always Source: https://www.electron.build/docs/publish Example of setting up CI to publish on each commit using the 'always' publish option. ```json "dist": "electron-builder --publish always" ``` -------------------------------- ### Example macOS Kernel Extension Installation Script Source: https://www.electron.build/docs/tutorials/macos-kernel-extensions This shell script demonstrates unloading old kernel extensions, removing them, and then installing and loading new ones. Ensure the script is executable and starts with `#!/bin/sh`. ```shell #!/bin/sh echo "Unloading and uninstalling old extensions..." # unload old extensions sudo kextunload /Library/Extensions/myExt.kext # delete old extensions sudo rm -rf /Library/Extensions/myExtension.kext # install new extensions echo "Installing and loading new extensions..." sudo cp -R myExt.kext /Library/Extensions/myExt.kext sudo kextload /Library/Extensions/myExt.kext/ ``` -------------------------------- ### beforeBuild Hook Example Source: https://www.electron.build/docs/features/hooks The `beforeBuild` hook runs before native dependencies are installed or rebuilt. It can be used to skip dependency installation by returning `false`. ```javascript beforeBuild: async (context) => { // context: BeforeBuildContext // { appDir, electronVersion, platform, arch } console.log("Building for:", context.platform.name, context.arch) // return false to skip dependency install } ``` -------------------------------- ### ASAR Ordering File Content Example Source: https://www.electron.build/docs/contents Example content for the `build/asar-ordering.txt` file, listing files that are loaded at startup first to optimize read times. ```text # build/asar-ordering.txt — list files loaded at startup first index.js renderer.js node_modules/electron/index.js ``` -------------------------------- ### Install electron-builder Source: https://www.electron.build/docs Install electron-builder as a development dependency using yarn, npm, pnpm, or bun. ```bash yarn add electron-builder --dev // or npm, pnpm, bun ``` -------------------------------- ### artifactBuildStarted Hook Example Source: https://www.electron.build/docs/features/hooks The `artifactBuildStarted` hook runs when an individual artifact (e.g., DMG, NSIS installer) begins its build process. ```javascript artifactBuildStarted: async (context) => { // context: ArtifactBuildStarted // { targetPresentableName, file, safeArtifactName, packager, arch } console.log("Building artifact:", context.targetPresentableName) } ``` -------------------------------- ### Simple Include Example for `files` Option Source: https://www.electron.build/docs/contents A basic example of the `files` option to include all files, excluding source files, specific file types, and configuration files. ```yaml files: - "**/*" - "!src/**" - "!*.ts" - "!tsconfig*.json" ``` -------------------------------- ### Install snapcraft and multipass on Linux Source: https://www.electron.build/docs/features/multi-platform-build Installs snapcraft and multipass, required for building snap packages on Linux. ```shell sudo snap install snapcraft --classic sudo snap install multipass --beta --classic ``` -------------------------------- ### Install App Dependencies Source: https://www.electron.build/docs Add the 'postinstall' script to automatically install app dependencies matching the electron version. ```json "postinstall": "electron-builder install-app-deps" ``` -------------------------------- ### Build Windows Installer on Linux/macOS using Docker Source: https://www.electron.build/docs/architecture Cross-compile a Windows installer on Linux or macOS using a Wine-based Docker image. Wine is used for the NSIS installer generation, not for compiling the Electron binary. ```bash docker run --rm \ -v ${PWD}:/project \ -v ~/.cache/electron:/root/.cache/electron \ -v ~/.cache/electron-builder:/root/.cache/electron-builder \ electronuserland/builder:wine \ /bin/bash -c "npm ci && npx electron-builder --win" ``` -------------------------------- ### Linux Icon File Structure Example Source: https://www.electron.build/docs/features/icons-and-images Example of the expected file structure for Linux icon assets. Files must be named according to their pixel dimensions (e.g., 16x16.png). ```bash build/icons/ ├── 16x16.png ├── 32x32.png ├── 48x48.png ├── 128x128.png ├── 256x256.png └── 512x512.png ``` -------------------------------- ### Snapcraft Configuration Example Source: https://www.electron.build/docs/configuration Configures Snapcraft for building snap packages, specifying the base and core24 options. This is the preferred method over the deprecated 'snap' option. ```json { "snapcraft": { "base": "core24", "core24": { "useLXD": true } } } ``` -------------------------------- ### Install Linux build dependencies Source: https://www.electron.build/docs/features/multi-platform-build Installs necessary tools for building on Linux, specifically libopenjp2-tools for distributable formats. ```shell sudo apt-get install --no-install-recommends -y libopenjp2-tools ``` -------------------------------- ### beforePack Hook Example Source: https://www.electron.build/docs/features/hooks The `beforePack` hook executes before files are copied into the application bundle. ```javascript beforePack: async (context) => { // context: BeforePackContext // { outDir, appOutDir, packager, electronPlatformName, arch, targets } } ``` -------------------------------- ### Install NSIS Web Installer Maker for Electron Forge Source: https://www.electron.build/docs/features/electron-forge Install the NSIS web installer maker package as a development dependency. ```bash npm install --save-dev electron-forge-maker-nsis-web ``` -------------------------------- ### Build 32-bit NSIS Installer for Windows Source: https://www.electron.build/docs/cli Builds a 32-bit NSIS installer for Windows. This command allows for specific installer type and architecture selection. ```bash electron-builder --windows nsis:ia32 ``` -------------------------------- ### Setup Node.js and Cache npm Packages Source: https://www.electron.build/docs/features/github-actions Configures the Node.js environment for a GitHub Actions workflow and enables caching for npm packages to speed up subsequent builds. Uses the 'actions/setup-node' action. ```yaml - uses: actions/setup-node@v4 with: node-version: 20 cache: npm # caches ~/.npm ``` -------------------------------- ### electron-builder package.json script Source: https://www.electron.build/docs/publish Example of adding a 'release' script to package.json to automate publishing. ```json "release": "electron-builder" ``` -------------------------------- ### Build Multiple Architectures Sequentially (CLI) Source: https://www.electron.build/docs/architecture Build for multiple architectures for a given platform in sequence using CLI flags. This example shows building for both x64 and arm64 on Windows. ```bash electron-builder --win --x64 --arm64 ``` -------------------------------- ### Programmatic Build with Electron-Builder Source: https://www.electron.build/docs Use this snippet to initiate a build process programmatically. It specifies the target platform and configuration options. Ensure electron-builder is installed. ```javascript "use strict" const builder = require("electron-builder") const Platform = builder.Platform // Promise is returned builder.build({ targets: Platform.MAC.createTarget(), config: { "//": "build options, see https://www.electron.build/" } }) .then(() => { // handle result }) .catch((error) => { // handle error }) ``` -------------------------------- ### Rebuild Native Dependencies Source: https://www.electron.build/docs/features/build-lifecycle Fires before native dependency installation or rebuild. Returning `false` skips native dependency installation. ```javascript beforeBuild: async ({ appDir, electronVersion, platform, arch }) => { console.log(`Building native deps for ${platform.name} ${arch}`) // return false to skip; useful when node_modules are managed externally } ``` -------------------------------- ### Custom FileSet Configuration Source: https://www.electron.build/contents Example of using FileSet objects to specify custom source and destination directories for files during packaging. Includes filtering capabilities. ```json [ { "from": "path/to/source", "to": "path/to/destination", "filter": ["**/*", "!foo/*.js"] } ] ``` -------------------------------- ### Install 32-bit build tools on Linux Source: https://www.electron.build/docs/features/multi-platform-build Installs GCC and G++ for 32-bit architecture, enabling 32-bit builds from a 64-bit machine on Linux. ```shell sudo apt-get install --no-install-recommends -y gcc-multilib g++-multilib ``` -------------------------------- ### Install Snap Maker for Electron Forge Source: https://www.electron.build/docs/features/electron-forge Install the Snap maker package as a development dependency for your Electron Forge project. ```bash npm install --save-dev electron-forge-maker-snap ``` -------------------------------- ### Install bsdtar on Linux Source: https://www.electron.build/docs/features/multi-platform-build Installs bsdtar, a utility for creating and extracting archives, required for pacman builds on Linux. ```shell sudo apt-get install --no-install-recommends -y bsdtar ``` -------------------------------- ### Example S3 Publish Configuration Source: https://www.electron.build/docs/publish This JSON snippet shows a basic configuration for publishing to S3, specifying the provider and bucket name. ```json { "build": { "publish": { "provider": "s3", "bucket": "bucket-name" } } } ``` -------------------------------- ### afterPack Hook Example - Add Version File Source: https://www.electron.build/docs/features/hooks The `afterPack` hook runs after the app is fully packaged but before code signing. This example demonstrates adding a VERSION file to the app bundle. ```javascript afterPack: async (context) => { // context: AfterPackContext // { outDir, appOutDir, packager, electronPlatformName, arch, targets } const path = require("path") const fs = require("fs") // Example: add a VERSION file to the app bundle const versionFile = path.join(context.appOutDir, "VERSION") fs.writeFileSync(versionFile, context.packager.appInfo.version) } ``` -------------------------------- ### Multiple Glob Patterns Example Source: https://www.electron.build/docs/file-patterns Demonstrates how to use multiple glob patterns to include and exclude files. Use this to define a set of files for your build, excluding specific types or files while including others. ```json [ // match all files "**/*", // except for js files in the foo/ directory "!foo/*.js", // unless it's foo/bar.js "foo/bar.js", ] ``` -------------------------------- ### Install Rosetta 2 on Apple Silicon Source: https://www.electron.build/docs/troubleshooting For applications that are x64-only on Apple Silicon Macs, ensure Rosetta 2 is installed to enable x64 execution. ```bash softwareupdate --install-rosetta ``` -------------------------------- ### Include Specific Directories with `files` Option Source: https://www.electron.build/docs/contents Example demonstrating how to explicitly include specific directories like `dist` and `assets`, along with production `node_modules` and `package.json`. ```yaml files: - dist/** - assets/** - node_modules/** - package.json ``` -------------------------------- ### JSign Signing Script Example Source: https://www.electron.build/docs/tutorials/code-signing-windows-apps-on-unix A JavaScript file to execute JSign for code signing. It reads certificate name and token password from environment variables and constructs the command-line arguments for JSign. ```javascript exports.default = async function(configuration) { // do not include passwords or other sensitive data in the file // rather create environment variables with sensitive data const CERTIFICATE_NAME = process.env.WINDOWS_SIGN_CERTIFICATE_NAME; const TOKEN_PASSWORD = process.env.WINDOWS_SIGN_TOKEN_PASSWORD; require("child_process").execSync( // your commande here ! For exemple and with JSign : `java -jar jsign-2.1.jar --keystore hardwareToken.cfg --storepass "${TOKEN_PASSWORD}" --storetype PKCS11 --tsaurl http://timestamp.digicert.com --alias "${CERTIFICATE_NAME}" "${configuration.path}"`, { stdio: "inherit" } ); }; ``` -------------------------------- ### electronDist Hook Example Source: https://www.electron.build/docs/features/hooks The `electronDist` hook allows you to provide a custom Electron binary instead of the standard downloaded one. It should return the path to a custom Electron build or a directory of Electron zip files. ```javascript electronDist: async (context) => { // Return path to custom Electron directory return "/path/to/custom/electron-dist" } ``` -------------------------------- ### Build Linux ARM64 AppImage using Docker Source: https://www.electron.build/docs/architecture Build an ARM64 AppImage for Linux on an x64 machine using Docker with QEMU emulation. Ensure Node.js dependencies are installed within the container. ```bash # Build ARM64 AppImage docker run --rm \ -v ${PWD}:/project \ -v ~/.cache/electron:/root/.cache/electron \ -v ~/.cache/electron-builder:/root/.cache/electron-builder \ --platform linux/arm64 \ electronuserland/builder \ /bin/bash -c "npm ci && npx electron-builder --linux --arm64" ``` -------------------------------- ### Monorepo Setup Configuration Source: https://www.electron.build/docs/contents Configure a monorepo structure by specifying the `app` directory within the `directories` setting. This is useful when the application code is not in the project root. ```yaml directories: app: packages/app # app directory is not the project root files: - "**/*" - "!src/**" ``` -------------------------------- ### syncDesktopName Source: https://www.electron.build/docs/linux Determines if the installed desktop filename should be derived from `desktopName` in `package.json`. When true, it ensures the filename matches `StartupWMClass` and Electron's `app_id`. Defaults to false. ```APIDOC ## syncDesktopName ### Description When `true`, the installed `.desktop` filename is derived from `desktopName` in `package.json` (minus the `.desktop` suffix) so that it matches `StartupWMClass` and Electron's `app_id`. Falls back to `executableName` when `desktopName` is absent. ### Method Not applicable (configuration option) ### Endpoint Not applicable (configuration option) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **syncDesktopName** (boolean) - Indicates if desktop filename should sync with package.json desktopName. #### Response Example ```json { "syncDesktopName": false } ``` ``` -------------------------------- ### GitHub Actions Workflow for macOS Build and Notarization Source: https://www.electron.build/docs/features/github-actions A GitHub Actions workflow that checks out code, sets up Node.js, installs dependencies, and then builds and notarizes the Electron application for macOS. It utilizes environment variables for code signing credentials and other necessary secrets. ```yaml build-mac: runs-on: macos-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 cache: npm - name: Install dependencies run: npm ci - name: Build and notarize run: npx electron-builder --mac --publish always env: CSC_LINK: ${{ secrets.MAC_CSC_LINK }} CSC_KEY_PASSWORD: ${{ secrets.MAC_CSC_KEY_PASSWORD }} APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` -------------------------------- ### Prepare for File Copying Source: https://www.electron.build/docs/features/build-lifecycle Fires before any file copying begins. The staging directory (`appOutDir`) is created but empty at this point. ```javascript beforePack: async ({ outDir, appOutDir, packager, electronPlatformName, arch, targets }) => { // Generate files that need to be in the build } ``` -------------------------------- ### Customize MSI project before compilation Source: https://www.electron.build/docs/features/build-lifecycle The `msiProjectCreated` hook allows modification of the WiX `.wxs` file before it is compiled into an MSI installer. This example updates the manufacturer name. ```javascript // Edit the WiX XML before MSI compilation msiProjectCreated: async (wixProjectPath) => { const fs = require("fs") const wxsPath = require("path").join(wixProjectPath, "installer.wxs") let xml = fs.readFileSync(wxsPath, "utf8") xml = xml.replace('Manufacturer="PLACEHOLDER"', 'Manufacturer="Acme Corp"') fs.writeFileSync(wxsPath, xml) } ``` -------------------------------- ### Customize Linux .desktop File Source: https://www.electron.build/docs/linux Configure application menu integration by defining properties like Name, Comment, Categories, and StartupWMClass in the `linux.desktop` configuration. ```yaml linux: desktop: entry: Name: My Application Comment: A fantastic application Categories: Office;Productivity Keywords: productivity;notes;organizer StartupWMClass: my-app # helps window managers match window to icon Terminal: false Type: Application desktopActions: NewWindow: Name: New Window Exec: my-app --new-window NewFile: Name: New File Exec: my-app --new-file ``` -------------------------------- ### Install rpm on macOS Source: https://www.electron.build/docs/features/multi-platform-build Installs the rpm package manager on macOS using Homebrew. ```shell brew install rpm ``` -------------------------------- ### electron-builder CLI --publish option Source: https://www.electron.build/docs/publish Shows the available choices for the --publish CLI option. ```bash Publishing: --publish, -p [choices: "onTag", "onTagOrDraft", "always", "never"] ``` -------------------------------- ### Install rpm on Linux Source: https://www.electron.build/docs/features/multi-platform-build Installs the rpm package manager on Debian/Ubuntu-based systems or RHEL/CentOS-based systems. ```shell sudo apt-get install --no-install-recommends -y rpm ``` ```shell sudo yum install rpm-build ``` -------------------------------- ### Install FUSE for AppImage on Fedora Source: https://www.electron.build/docs/troubleshooting The AppImage runtime requires FUSE. Install the necessary packages on Fedora-based systems. ```bash sudo dnf install fuse fuse-libs ``` -------------------------------- ### Install FUSE for AppImage on Ubuntu/Debian Source: https://www.electron.build/docs/troubleshooting The AppImage runtime requires FUSE. Install the necessary packages on Ubuntu or Debian-based systems. ```bash sudo apt install fuse libfuse2 ``` -------------------------------- ### Configure Window Association with package.json Source: https://www.electron.build/docs/linux Set `desktopName` in `package.json` and enable `linux.syncDesktopName` to ensure the application's WM_CLASS matches its .desktop file for correct window association in desktop environments. ```json { "desktopName": "com.example.MyApp.desktop", "build": { "linux": { "syncDesktopName": true } } } ``` -------------------------------- ### Install AppImage Maker for Electron Forge Source: https://www.electron.build/docs/features/electron-forge Install the AppImage maker package as a development dependency for your Electron Forge project. ```bash npm install --save-dev electron-forge-maker-appimage ``` -------------------------------- ### Install NSIS Maker for Electron Forge Source: https://www.electron.build/docs/features/electron-forge Install the NSIS maker package as a development dependency for your Electron Forge project. ```bash npm install --save-dev electron-forge-maker-nsis ``` -------------------------------- ### Configure NSIS Web Installer Maker in forge.config.js Source: https://www.electron.build/docs/features/electron-forge Configure the NSIS web installer maker in your forge.config.js file. This maker extends NsisOptions. ```javascript const { MakerNsisWeb } = require("electron-forge-maker-nsis-web") module.exports = { makers: [ new MakerNsisWeb({ // NsisWebOptions — extends NsisOptions }), ], } ``` -------------------------------- ### Configure NSIS and DMG Targets in electron-builder.config.js Source: https://www.electron.build/docs/cli Set up build targets and architectures for Windows (NSIS) and macOS (DMG) in the electron-builder.config.js file. ```javascript module.exports = { "win": { "target": [ { "target": "nsis", "arch": [ "x64", "ia32" ] } ] }, "mac": { "target": [ { "target": "dmg", "arch": [ "universal" ] } ] } } ``` -------------------------------- ### Build Universal macOS Binary (CLI) Source: https://www.electron.build/docs/architecture Build a universal macOS binary that runs natively on both Intel and Apple Silicon. This is the recommended approach for broad compatibility. ```bash electron-builder --mac --universal ``` -------------------------------- ### Electron-Builder Build Lifecycle Overview Source: https://www.electron.build/docs/features/build-lifecycle This diagram outlines the complete build flow of electron-builder, detailing each phase from configuration to artifact publication and the associated hooks. ```text electron-builder build │ ├─ 1. Configuration & Validation │ └─ Load config, merge platform defaults, resolve output paths │ ├─ 2. For each Platform × Architecture │ │ │ ├─ 2a. Install / Rebuild Native Deps │ │ └─ 🪝 beforeBuild │ │ │ ├─ 2b. Pre-Pack │ │ └─ 🪝 beforePack │ │ │ ├─ 2c. Extract Electron Binary → staging dir │ │ └─ 🪝 afterExtract │ │ │ ├─ 2d. Copy App Files │ │ ├─ Filter via files / file patterns │ │ ├─ Pack node_modules (honor onNodeModuleFile) │ │ ├─ Create ASAR archive (if enabled) │ │ ├─ Copy extraResources │ │ └─ Copy extraFiles │ │ │ ├─ 2e. Post-Pack (before signing) │ │ └─ 🪝 afterPack │ │ │ ├─ 2f. Apply Electron Fuses (if configured) │ │ │ ├─ 2g. Code Sign the .app / .exe │ │ └─ 🪝 afterSign (only fires if signing actually ran) │ │ │ └─ 2h. Build Distributables — For each Target │ ├─ 🪝 artifactBuildStarted │ ├─ [Target-specific build — see per-target section below] │ └─ 🪝 artifactBuildCompleted │ └─ Publish Manager schedules artifact upload │ ├─ 3. All Builds Complete │ └─ 🪝 afterAllArtifactBuild │ └─ 4. Publish └─ Upload all queued artifacts to configured providers ``` -------------------------------- ### Log artifact build start Source: https://www.electron.build/docs/features/build-lifecycle The `artifactBuildStarted` hook logs a message indicating the start of a specific artifact's build process. It provides details about the target and file being built. ```javascript artifactBuildStarted: async ({ targetPresentableName, file, safeArtifactName, packager, arch }) => { console.log(`Starting: ${targetPresentableName}`) } ``` -------------------------------- ### NSIS Installer Image Configuration Source: https://www.electron.build/docs/features/icons-and-images Configure the paths for various image assets used in the NSIS installer, including header banners, sidebars, and icons. BMP files must be 24-bit RGB. ```yaml nsis: installerHeader: build/installerHeader.bmp installerSidebar: build/installerSidebar.bmp uninstallerSidebar: build/uninstallerSidebar.bmp installerIcon: build/installerIcon.ico uninstallerIcon: build/uninstallerIcon.ico ``` -------------------------------- ### verifyUpdateCodeSignature Source: https://www.electron.build/docs/win Determines whether to verify the code signature of an available update before installation. ```APIDOC ## verifyUpdateCodeSignature ### Description Whether to verify the signature of an available update before installation. The publisher name will be used for the signature verification. ### Parameters #### Query Parameters - **verifyUpdateCodeSignature** (boolean) - Optional - Whether to verify the signature of an available update before installation. ### Default true ``` -------------------------------- ### Set Release Notes for Command Line Source: https://www.electron.build/docs/mac Use this option to specify release notes directly from the command line when building. ```bash -c.releaseInfo.releaseNotes="new features" ``` -------------------------------- ### Build and Publish Linux Snapcraft Package Source: https://www.electron.build/docs/features/github-actions A GitHub Actions step to build and publish an Electron application as a Linux Snapcraft package. Requires Snapcraft store credentials and a GitHub token to be set as secrets. ```yaml - name: Build and publish Snap run: npx electron-builder --linux snap --publish always env: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` -------------------------------- ### Configure Electron-Updater Logger Source: https://www.electron.build/docs/features/auto-update Set up electron-log for debugging auto-update events. Ensure electron-log is installed as a dependency. ```javascript autoUpdater.logger = require("electron-log") autoUpdater.logger.transports.file.level = "info" ``` -------------------------------- ### MsiOptions Properties Source: https://www.electron.build/docs/api/app-builder-lib.Interface.WindowsSigntoolConfiguration This section details the properties available for the MsiOptions interface, which are used to customize the MSI installation process. ```APIDOC ## Interface: MsiOptions ### Properties #### additionalLightArgs * **Type**: `string[] | null` * **Readonly**: `true` * **Optional**: `true` * **Description**: Any additional arguments to be passed to the light.ext, such as `["-cultures:ja-jp"]`. #### additionalWixArgs * **Type**: `string[] | null` * **Readonly**: `true` * **Optional**: `true` * **Description**: Any additional arguments to be passed to the WiX installer compiler, such as `["-ext", "WixUtilExtension"]`. #### artifactName * **Type**: `string | null` * **Readonly**: `true` * **Optional**: `true` * **Description**: The artifact file name template. * **Inherited from**: `TargetSpecificOptions.artifactName` #### createDesktopShortcut * **Type**: `boolean | "always"` * **Readonly**: `true` * **Optional**: `true` * **Default**: `true` * **Description**: Whether to create desktop shortcut. Set to `always` if to recreate also on reinstall (even if removed by user). * **Inherited from**: `CommonWindowsInstallerConfiguration.createDesktopShortcut` #### createStartMenuShortcut * **Type**: `boolean` * **Readonly**: `true` * **Optional**: `true` * **Default**: `true` * **Description**: Whether to create start menu shortcut. * **Inherited from**: `CommonWindowsInstallerConfiguration.createStartMenuShortcut` #### menuCategory * **Type**: `string | boolean` * **Readonly**: `true` * **Optional**: `true` * **Default**: `false` * **Description**: Whether to create submenu for start menu shortcut and program files directory. If `true`, company name will be used. Or string value. * **Inherited from**: `CommonWindowsInstallerConfiguration.menuCategory` #### oneClick * **Type**: `boolean` * **Readonly**: `true` * **Optional**: `true` * **Default**: `true` * **Description**: One-click installation. * **Overrides**: `CommonWindowsInstallerConfiguration.oneClick` #### perMachine * **Type**: `boolean` * **Readonly**: `true` * **Optional**: `true` * **Default**: `false` * **Description**: Whether to install per all users (per-machine). * **Inherited from**: `CommonWindowsInstallerConfiguration.perMachine` #### publish * **Type**: `Publish` * **Optional**: `true` * **Inherited from**: `TargetSpecificOptions.publish` #### runAfterFinish * **Type**: `boolean` * **Readonly**: `true` * **Optional**: `true` * **Default**: `true` * **Description**: Whether to run the installed application after finish. For assisted installer corresponding checkbox will be removed. * **Inherited from**: `CommonWindowsInstallerConfiguration.runAfterFinish` #### shortcutName * **Type**: `string | null` * **Readonly**: `true` * **Optional**: `true` * **Description**: The name that will be used for all shortcuts. Defaults to the application name. * **Inherited from**: `CommonWindowsInstallerConfiguration.shortcutName` #### upgradeCode * **Type**: `string | null` * **Readonly**: `true` * **Optional**: `true` * **Description**: The upgrade code. Optional, by default generated using app id. #### warningsAsErrors * **Type**: `boolean` * **Readonly**: `true` * **Optional**: `true` * **Default**: `true` * **Description**: If `warningsAsErrors` is `true` (default): treat warnings as errors. If `warningsAsErrors` is `false`: allow warnings. ``` -------------------------------- ### Build for All Configured Targets and Architectures (CLI) Source: https://www.electron.build/docs/architecture Build for all configured targets and architectures across multiple platforms using a single CLI command. ```bash electron-builder --mac --win --linux ``` -------------------------------- ### Build for macOS, Windows, and Linux Source: https://www.electron.build/docs/cli Builds the application for macOS, Windows, and Linux platforms simultaneously. This is a common shortcut for multi-platform builds. ```bash electron-builder -mwl ``` -------------------------------- ### RPM Package After-Install and After-Remove Scripts Source: https://www.electron.build/docs/linux Specify custom shell scripts to be executed after the RPM package installation or removal. ```yaml rpm: afterInstall: build/scripts/after-install.sh afterRemove: build/scripts/after-remove.sh ``` -------------------------------- ### Build All Configured Targets via CLI Source: https://www.electron.build/docs/targets Execute electron-builder from the command line to build all targets specified in the configuration file for macOS, Windows, and Linux. ```bash # CLI: build all configured targets electron-builder --mac --win --linux ``` -------------------------------- ### Default Native Rebuilder Configuration Source: https://www.electron.build/docs/configuration Specifies the compilation mode for installing native dependencies using the app-builder binary or @electron/rebuild. ```yaml sequential ``` -------------------------------- ### Execute Custom Code Signing Source: https://www.electron.build/configuration Example of a custom code signing script for macOS. It uses `codesign` to sign the application deeply. ```javascript // scripts/sign.js exports.default = async function(configuration) { // configuration: CustomMacSign // { path, packager, entitlements, ... } const { execSync } = require("child_process") execSync(`codesign --deep --sign "${configuration.identity}" "${configuration.path}"`) } ``` -------------------------------- ### AppImage Workaround for Update Source: https://www.electron.build/docs/features/auto-update A workaround for the 'APPIMAGE env is not defined' error, allowing the update to continue. Not recommended for production; testing installed applications is preferred. ```javascript process.env.APPIMAGE = path.join(__dirname, 'dist', `app_name-${app.getVersion()}.AppImage`) ``` -------------------------------- ### Configure NSIS Unicode Options Source: https://www.electron.build/docs/cli Configures the NSIS installer to disable Unicode support. This is important for compatibility with older systems or specific build requirements. ```bash electron-builder -c.nsis.unicode=false ``` -------------------------------- ### Build for Windows and Linux CLI command Source: https://www.electron.build/docs/cli Use the CLI command to build for Windows and Linux platforms. ```bash build -wl ``` -------------------------------- ### Publish to Local Minio Source: https://www.electron.build/docs/tutorials/test-update-on-s3-locally Use this command to publish your application artifacts to a local Minio instance. Ensure your Minio credentials and endpoint are correctly set as environment variables or within your configuration. ```bash electron-builder --publish always \ --config.publish.provider=s3 \ --config.publish.endpoint=http://localhost:9000 \ --config.publish.bucket=test-bucket ``` -------------------------------- ### Custom Code Signing Script (macOS) Source: https://www.electron.build/docs/configuration An example script for custom code signing on macOS. It uses the 'child_process' module to execute the 'codesign' command. ```javascript // scripts/sign.js exports.default = async function(configuration) { // configuration: CustomMacSign // { path, packager, entitlements, ... } const { execSync } = require("child_process") execSync(`codesign --deep --sign "${configuration.identity}" "${configuration.path}"`) } ``` -------------------------------- ### Modify Info.plist After Pack (macOS) Source: https://www.electron.build/docs/configuration This example demonstrates how to modify the Info.plist file for macOS applications after they have been packed. It requires the 'path', 'plist', and 'fs' modules. ```javascript const path = require("path") const plist = require("plist") const fs = require("fs") afterPack: async (context) => { if (context.electronPlatformName !== "darwin") return const plistPath = path.join( context.appOutDir, `${context.packager.appInfo.productFilename}.app`, "Contents", "Info.plist" ) const plistData = plist.parse(fs.readFileSync(plistPath, "utf8")) plistData.LSUIElement = true // Hide from dock fs.writeFileSync(plistPath, plist.build(plistData)) } ``` -------------------------------- ### Run Electron build container with Wine Source: https://www.electron.build/docs/features/multi-platform-build Executes a Docker container for building Windows targets on any platform. It mounts the current directory and caches, and sets environment variables for the build process. ```shell docker run --rm -ti \ --env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \ --env ELECTRON_CACHE="/root/.cache/electron" \ --env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \ -v ${PWD}:/project \ -v ${PWD##*/}-node-modules:/project/node_modules \ -v ~/.cache/electron:/root/.cache/electron \ -v ~/.cache/electron-builder:/root/.cache/electron-builder \ electronuserland/builder:wine ```