Replace electron with Bun compile for single-file exe distribution

This commit is contained in:
2026-03-13 04:57:12 +08:00
parent a078666173
commit 181168cba5
10 changed files with 522 additions and 5210 deletions

View File

@@ -63,19 +63,23 @@ All scripts are in `package.json`.
## Distribution
## Electron single-exe distribution
To package as a single portable exe with built-in server:
## Single-file exe distribution
To build a standalone executable with embedded static files:
```bash
cd web/electron
npx electron-builder --win --x64
cd web
bun run build:exe
```
Output: `web/electron/release/OpenChamber.exe` (single portable exe, ~260MB)
Output: `web/OpenChamber.exe` (~320MB single file)
The exe includes:
- Bundled Node.js runtime
- Server code, static files, and CLI
- System tray icon with context menu
- Auto-starts server on port 3000
- Bun runtime
- Server code and all dependencies
- 300+ static files (dist/, embedded)
- Extracts static files to temp directory on startup
Files involved:
- `web/entry-singlefile.js` - Entry point for compiled exe
- `web/embed-static.js` - Script to embed dist/ as base64
## Runtime entry points
- Web bootstrap: `web/src/main.tsx`