A Production-Ready Electron 25+ Config Stack, Hardened for Medical Desktop Apps
Most Electron tutorials stop at “hello world” window creation. This configuration set solves the real problems that surface when a desktop app must record audio in the background, open multiple modal windows, survive restrictive intranet policies, and lock down the renderer enough to pass a healthcare security review—all with a single, copyable webPreferences block.
The reference distills a hospital bed-rounds desktop system into a full-stack configuration blueprint for Electron 25 and above. It walks through five layers: package.json scaffolding, main-process lifecycle hooks, every BrowserWindow option, a security-hardened webPreferences block, and electron-builder packaging for Windows, macOS, and Linux. Each parameter is annotated with its default, risk level, and the specific production value used in the medical deployment.
Security is the backbone. The renderer runs with nodeIntegration off, contextIsolation and sandbox on, and all privileged operations—microphone access, file I/O, IPC—funneled through a single preload script using contextBridge. A separate temporary config is provided for Vue dev work, with explicit warnings to restore the locked-down settings before packaging.
Domain-specific adaptations fill the gaps that generic Electron docs leave open. Command-line switches disable the GPU sandbox to unblock Windows audio capture, background throttling is killed so recording never cuts out when the window loses focus, and certificate-error handlers trust internal hospital certificates. The packaging section covers NSIS installer customization, ASAR unpacking for native modules like ffmpeg, and generic-server auto-update feeds for air-gapped intranets.
Electron’s default security posture has tightened considerably since v20—sandbox now defaults to true—but the docs still scatter the implications across multiple pages, making a single annotated config block unusually valuable.
The medical-domain constraints (background recording, modal multi-window, intranet CAs) expose failure modes that generic Electron guides never test: GPU sandboxing blocking microphone access, background throttling killing timers, and ASAR archives breaking native module loading.
Packaging for an air-gapped hospital intranet forces decisions that SaaS-oriented Electron apps skip entirely—generic-server update feeds, NSIS install-path control, and certificate-error handlers become hard requirements rather than nice-to-haves.