Demonstrates integrating electron-asar-updater into a standard electron-vite project.
├── build/
│ └── afterpack.js ← electron-builder afterPack hook
├── src/
│ ├── main/index.js ← main process (your app logic)
│ ├── preload/index.js ← preload script
│ └── renderer/
│ ├── index.html ← renderer entry
│ └── src/main.js ← renderer JS
├── bootstrap.js ← bootstrap entry (generated by `init`, production only)
├── electron.vite.config.mjs
├── electron-builder.yml
└── package.json
Development (npm run dev): electron-vite runs as usual — src/main/index.js is the entry, HMR works for the renderer. bootstrap.js is not involved.
Production build (npm run build):
electron-vite buildcompilessrc/→out/(main, preload, renderer)electron-builderpacks everything intoapp.asaras normalafterpack.jshook runs:- Renames
app.asar→core.asar(contains your full app) - Signs
core.asarwith RSA-SHA256 (signature embedded in file tail) - Creates a new minimal
app.asarcontaining onlybootstrap.js+electron-asar-updater
- Renames
Runtime: Electron loads app.asar/bootstrap.js → bootstrap() verifies and loads core.asar.
# Install dependencies
npm install
# Generate keys + bootstrap.js (public key auto-embedded)
npx electron-asar-updater initnpm run dev# Build for current platform
npm run build
# Or target a specific platform
npm run build:win
npm run build:mac
npm run build:linuxAfter building, use the shared demo server to test the full update flow:
cd ../demo && npm install
npm run demo:viteThen launch the built app and click "Check for Update" → "Restart Now" → see v2.0.0.
Only 3 additions to a normal electron-vite setup:
| File | Purpose |
|---|---|
bootstrap.js |
Bootstrap that loads core.asar in production |
build/afterpack.js |
Renames + signs asar during build |
afterPack in electron-builder.yml |
Points to the hook |
Everything else (electron-vite config, src/ structure, dev workflow) stays exactly the same.