Configs2026年7月17日·1 分钟阅读

Electron Builder — Package Electron Apps for Every Platform

A complete solution for packaging and distributing Electron applications, supporting auto-update, code signing, and publishing to multiple stores from a single configuration.

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 29/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Stage only
信任
信任等级:Established
入口
Electron Builder Overview
安全暂存命令
npx -y tokrepo@latest install d6f21152-819a-11f1-9bc6-00163e2b0d79 --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

Introduction

Electron Builder is the standard packaging and distribution tool for Electron applications. It handles code signing, notarization, auto-update, and installer creation for macOS, Windows, and Linux from a single declarative configuration in package.json or electron-builder.yml.

What Electron Builder Does

  • Creates native installers: DMG and PKG for macOS, NSIS and MSI for Windows, AppImage, deb, rpm, and snap for Linux
  • Signs and notarizes macOS builds with Apple Developer credentials
  • Signs Windows executables with EV or standard code-signing certificates
  • Generates auto-update metadata for seamless in-app updates via electron-updater
  • Publishes artifacts to GitHub Releases, S3, or custom update servers

Architecture Overview

Electron Builder reads a declarative config that specifies per-platform targets, then orchestrates a build pipeline: it copies the app source, installs production dependencies, compiles native modules for the target arch, applies code signing, and finally invokes platform-specific packaging tools (NSIS, appdmg, rpmbuild) to produce distributable installers.

Self-Hosting and Configuration

  • Add an electron-builder.yml or a build key in package.json to configure targets
  • Set CSC_LINK and CSC_KEY_PASSWORD environment variables for code signing
  • Use publish configuration to target GitHub Releases, S3, or a generic server
  • Multi-arch builds (x64 and arm64) are supported via the --arch flag
  • CI integration works out of the box with GitHub Actions, GitLab CI, and CircleCI

Key Features

  • Single config file drives all platforms and architectures
  • Differential updates reduce download sizes for returning users
  • Native module rebuilding for the target Electron version is automatic
  • ASAR packing with optional per-file unpack rules for performance
  • Monorepo-friendly with workspace and custom directory support

Comparison with Similar Tools

  • Electron Forge — offers a more opinionated plugin-based workflow; Electron Builder gives finer control over installer output
  • electron-packager — lower-level tool that only bundles the app without creating installers or handling signing
  • Tauri — Rust-based alternative to Electron itself, not a packaging tool for existing Electron apps
  • pkg — packages Node.js apps into executables but does not target the Electron runtime

FAQ

Q: Can I build for macOS from a Linux CI runner? A: DMG and PKG targets require macOS. You can build non-signed zip targets on Linux but notarization needs a Mac.

Q: How does auto-update work? A: Electron Builder generates update metadata files. The companion library electron-updater checks these files at runtime and applies delta or full updates.

Q: Is ASAR packing required? A: No, but it is enabled by default. It bundles app files into a single archive for faster reads and to prevent casual source inspection.

Q: Does it support Apple Silicon natively? A: Yes. Pass --arm64 or --universal to produce native Apple Silicon or universal binaries.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产