From e8dea79309b5d0b9b198b8bff4f1056f8fa207f0 Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Wed, 9 Oct 2024 16:27:35 -0300 Subject: [PATCH] electron: Fix build code for `vite-plugin-electron` to activate HMR --- electron/main.ts | 6 +++++- vite.config.ts | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/electron/main.ts b/electron/main.ts index 2e9004385..f1f527c60 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -29,7 +29,11 @@ function createWindow(): void { mainWindow?.webContents.send('main-process-message', new Date().toLocaleString()) }) - mainWindow.loadFile(join(ROOT_PATH.dist, 'index.html')) + if (process.env.VITE_DEV_SERVER_URL) { + mainWindow.loadURL(process.env.VITE_DEV_SERVER_URL) + } else { + mainWindow.loadFile(join(ROOT_PATH.dist, 'index.html')) + } } app.on('window-all-closed', () => { diff --git a/vite.config.ts b/vite.config.ts index 8957b4dd4..e2f838505 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -9,10 +9,13 @@ const path = require('path') // eslint-disable-line @typescript-eslint/no-var-re export default defineConfig({ plugins: [ electron({ - main: { - entry: 'electron/main.ts', + entry: 'electron/main.ts', + vite: { + build: { + outDir: 'dist/electron', + }, }, - }).filter((configuration) => configuration.apply === 'build'), + }), vue(), vuetify({ autoImport: true,