diff --git a/src/index.ts b/src/index.ts index 1fe907b..46b3f22 100644 --- a/src/index.ts +++ b/src/index.ts @@ -92,14 +92,11 @@ export default function electron(options: ElectronOptions | ElectronOptions[]): options.onstart.call(this, { startup, // Why not use Vite's built-in `/@vite/client` to implement Hot reload? - // Because Vite only inserts `/@vite/client` into the `*.html` entry file, the preload scripts are usually a `*.js` file. + // Because Vite only inserts `/@vite/client` into the `*.html` entry file. // @see - https://github.com/vitejs/vite/blob/v5.2.11/packages/vite/src/node/server/middlewares/indexHtml.ts#L399 reload() { if (process.electronApp) { (server.hot || server.ws).send({ type: 'full-reload' }) - - // For Electron apps that don't need to use the renderer process. - startup.send('electron-vite&type=hot-reload') } else { startup() } @@ -168,10 +165,7 @@ export async function startup( await startup.exit() // Start Electron.app - process.electronApp = spawn(electronPath, argv, { - stdio: ['inherit', 'inherit', 'inherit', 'ipc'], - ...options, - }) + process.electronApp = spawn(electronPath, argv, { stdio: 'inherit', ...options }) // Exit command after Electron.app exits process.electronApp.once('exit', process.exit) @@ -181,14 +175,6 @@ export async function startup( process.once('exit', startup.exit) } } - -startup.send = (message: string) => { - if (process.electronApp) { - // Based on { stdio: [,,, 'ipc'] } - process.electronApp.send?.(message) - } -} - startup.hookedProcessExit = false startup.exit = async () => { if (process.electronApp) {