Registry / devops / vite-electron-plugin

vite-electron-plugin

JSON →
library0.8.3jsnpmunverified

High-performance Vite plugin for Electron development (v0.8.3). Uses esbuild under the hood for fast transforms, supports hot restart and plugin system similar to Vite's own plugin API. Unlike electron-vite, this plugin integrates into an existing Vite config rather than requiring a separate Vite config for Electron. Active development with frequent releases. Ships TypeScript types. Peer dependencies: acorn, esbuild.

npm install vite-electron-plugin
INSTALL
IMPORT
SIG · VITE-ELECTRON-PLUG
V
vite-electron-plugin
devopsjavascriptv0.8.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (plugin)
import electron from 'vite-electron-plugin'
const { electron } = require('vite-electron-plugin')
Package exports a default function; use ESM import.
type Plugin
import type { Plugin } from 'vite-electron-plugin'
import { Plugin } from 'vite-electron-plugin'
Plugin is a type, use import type to avoid runtime errors.
type Configuration
import type { Configuration } from 'vite-electron-plugin'
const { Configuration } = require('vite-electron-plugin')
Configuration is a type export.

Sets up vite-electron-plugin in a Vite config and creates a basic Electron main process entry.

// vite.config.ts import { defineConfig } from 'vite' import electron from 'vite-electron-plugin' export default defineConfig({ plugins: [ electron({ include: [ // The Electron source code directory 'electron', ], }), ], }) // electron/main.ts import { app, BrowserWindow } from 'electron' app.whenReady().then(() => { const win = new BrowserWindow() if (process.env.VITE_DEV_SERVER_URL) { win.loadURL(process.env.VITE_DEV_SERVER_URL) } else { win.loadFile('dist/index.html') } })
Debug
Known issues
breakingIn v0.7.0, the package renamed from 'vite-plugin-electron' to 'vite-electron-plugin'. Old imports break.
fix
Update all imports from 'vite-plugin-electron' to 'vite-electron-plugin'.
affects: <0.7.0
gotchaThe 'include' option paths are relative to 'root' (default process.cwd()). Absolute paths must be subpaths of root or output file paths will be incorrect.
fix
Use relative paths (e.g., 'electron') or absolute paths that are subdirectories of root.
affects: >=0.0.0
deprecatedThe 'api' option is deprecated in v0.8.0. Use plugin context instead.
fix
Remove 'api' from config and use plugin hooks to pass data.
affects: >=0.8.0 <0.8.0
gotchaHot restart requires the Electron main process to handle process.env.VITE_DEV_SERVER_URL. Missing this conditional can cause white screen.
fix
Ensure Electron main code checks process.env.VITE_DEV_SERVER_URL and loads the appropriate URL or file path.
affects: >=0.0.0
gotchaFiles ending with '.reload.js' or '.reload.ts' trigger a renderer reload instead of a full restart. Not using this convention can lead to unnecessary full restarts.
fix
Name preload scripts or other renderer-only files with the '.reload.extension' pattern to optimize development.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'vite-electron-plugin'
Package not installed or missing peer dependencies.
fix
Run: npm install vite-electron-plugin acorn esbuild
Error: The 'include' option must be a non-empty array
Missing or empty 'include' array in plugin config.
fix
Add include: ['electron'] (or your Electron source directory) to the plugin options.
TypeError: electron is not a function
Using named import instead of default import.
fix
Use: import electron from 'vite-electron-plugin' (not import { electron } from ...)
Error: The provided 'outDir' is not a subdirectory of 'root'
'outDir' is an absolute path not under 'root'.
fix
Use a relative path for outDir, e.g., 'dist-electron', or ensure absolute path is inside root.
Upgrade
Version history
0.8.3latest on npm
Audit
Dependencies
acornrequiredPeer dependency for parsing
esbuildrequiredPeer dependency used for fast transforms
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
vite-electron-plugin — npm install vite-electron-plugin · libregistry