vite-plugin-electron-x

A Vite plugin for bundling main.ts
, preload.ts
and running Electron in development.
Usage
Add the plugin in vite.config.js
like this:
export default defineConfig({
plugins: [
electronX({
main: {
entry: './src/electron/main.ts',
outDir: './build/electron',
},
preload: {
entry: './src/electron/preload.ts',
outDir: './build/electron',
},
}),
]
})
You can load the dev server in Electron using process.env.VITE_DEV_SERVER_URL
:
if (process.env.VITE_DEV_SERVER_URL) {
win.loadURL(`http://localhost:${process.env.VITE_DEV_SERVER_URL}`)
} else {
}
API
Docs: https://paka.dev/npm/vite-plugin-electron-x
Dev instructions
Get started
- Install Node.js
- Run
npm install
Commands
npm run dev
: Build and watchnpm run build
: Buildnpm run format
: Format
Publish new version
- Update
CHANGELOG.md
- Check for errors
npm run lint
- Bump the version number
npm version --no-git-tag <version>
- Build the package
npm run build
- Publish the package
npm publish
- Commit with a tag in format "v#.#.#"
- Create GitHub release with release notes