A Vite plugin that integrates Electron main process and preload scripts into the Vite build pipeline, supporting hot reload for main process via electron-rebuild (HMR). Current stable version is 0.29.1. The plugin automatically starts Electron after Vite server is ready and allows configuring entry files, build options, and external dependencies. Actively maintained with frequent releases. Key differentiator: full HMR support for Electron main process, unlike alternatives like electron-vite which require separate builds.
npm install vite-plugin-electronVerified import paths — ran on the pinned version, not inferred.
Configures Vite to build Electron main process and preload scripts with HMR support, using two plugin entries.
Upgrade to Vite 8 or stay on vite-plugin-electron <1.0.0-beta.1
Use import syntax or dynamic import() from CJS code.
Use array configuration with 'entry' and 'onstart' fields.
Call args.startup() in onstart callback to ensure proper process management.
Add 'electron' and other native modules to external in the Vite build config.
Add 'electron' to rollupOptions.external in the plugin's vite config.
Upgrade to >=0.28 and ensure onstart receives args object with startup method.
Add 'builtinModules' from 'module' module to external in rollupOptions.
Use args.startup() to manage lifecycle; consider using the 'onstart' callback to gracefully shut down.