feat: add Electron hot-reload development mode

- Add electron-dev.mjs script for hot-reload development
- Support automatic Electron dependency building
- Start Remix dev server and Electron app concurrently
- Add proper process management and cleanup
- Fix preload script path for development mode
- Add electron:dev and electron:dev:inspect npm scripts

This enables developers to run 'pnpm electron:dev' for a complete
hot-reload development experience with automatic rebuilding and
process management.
This commit is contained in:
zhaomenghuan02
2025-09-13 00:19:42 +08:00
parent 4ca535b9d1
commit 33725102e2
3 changed files with 187 additions and 1 deletions

View File

@@ -9,6 +9,9 @@ export function createWindow(rendererURL: string) {
const bounds = store.get('bounds');
console.log('restored bounds:', bounds);
// preload path
const preloadPath = path.join(isDev ? process.cwd() : app.getAppPath(), 'build', 'electron', 'preload', 'index.cjs');
const win = new BrowserWindow({
...{
width: 1200,
@@ -18,7 +21,7 @@ export function createWindow(rendererURL: string) {
vibrancy: 'under-window',
visualEffectState: 'active',
webPreferences: {
preload: path.join(app.getAppPath(), 'build', 'electron', 'preload', 'index.cjs'),
preload: preloadPath,
},
});