feat: modernize Electron build process with Vite-based CSS injection

- Replace manual CSS injection hack with Vite plugin
- Configure Vite to handle both main process and renderer builds
- Update build scripts to work with proper Vite output structure
- Remove fix-inject-css.js post-build script
- Update BUILDING.md documentation
- Add build-modernization-context.md for future reference

Technical changes:
- vite.config.electron.mts: Add electron-css-injection plugin and proper output config
- scripts/build-electron.js: Simplify to work with Vite-generated files
- BUILDING.md: Update Electron build documentation
- doc/build-modernization-context.md: Document context and decisions

Security/maintenance improvements:
- Eliminate manual file manipulation hacks
- Ensure deterministic, reproducible builds
- Centralize build logic in Vite configuration
- Improve developer experience and CI/CD compatibility

Author: Matthew Raymer
This commit is contained in:
Matthew Raymer
2025-06-25 10:46:11 +00:00
parent f57458835b
commit ca014a52de
6 changed files with 207 additions and 100 deletions

View File

@@ -634,3 +634,19 @@ For iOS deep links, configure the URL scheme in Xcode:
| `web` | web | true | false | Standard web browser |
| `capacitor` | capacitor | false | true | Mobile app (iOS/Android) |
| `electron` | electron | false | true | Desktop app (Windows/macOS/Linux) |
## Electron Build: CSS Injection
The Electron build now uses Vite's built-in CSS handling with a custom plugin (`electron-css-injection`) that automatically injects CSS links into the generated `index.html` file. This replaces the previous manual CSS injection script.
**Plugin:** `vite.config.electron.mts` - `electron-css-injection` plugin
**Features:**
- Automatically detects and injects CSS files generated by Vite
- Ensures proper relative paths for Electron builds
- Handles multiple CSS files if present
- Provides detailed logging during build process
**No manual intervention required** - CSS injection is handled automatically during the Vite build process.
**Author:** Matthew Raymer