From 3dc913ddc4886f81387858900aefd28f93ef5184 Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Thu, 10 Oct 2024 15:29:29 -0300 Subject: [PATCH] electron: Fix problem of having multiple windows created on dev mode --- vite.config.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index e2f838505..606ba500d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,6 +1,6 @@ import vue from '@vitejs/plugin-vue' import { defineConfig } from 'vite' -import electron from 'vite-plugin-electron' +import electron, { startup, treeKillSync } from 'vite-plugin-electron' import { VitePWA } from 'vite-plugin-pwa' import vuetify from 'vite-plugin-vuetify' @@ -15,6 +15,14 @@ export default defineConfig({ outDir: 'dist/electron', }, }, + onstart: () => { + // @ts-ignore: process.electronApp exists in vite-plugin-electron but not in the types + if (process.electronApp) { + // @ts-ignore: process.electronApp.pid exists in vite-plugin-electron but not in the types + treeKillSync(process.electronApp.pid) + } + startup() + }, }), vue(), vuetify({