diff --git a/package.json b/package.json index 3cba670d4..73037fac0 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "deploy:electron": "electron-builder --publish=never -c.extraMetadata.version=$(git describe --tags --abbrev=0 | sed 's/^v//')", "deploy:flatpak": "electron-builder --x64 --linux flatpak", "dev": "vite --host", + "dev:electron": "ELECTRON=true vite --host", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore --max-warnings=0", "lint:fix": "eslint --fix . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore --max-warnings=0", "preview": "vite preview --port 5050", diff --git a/vite.config.ts b/vite.config.ts index 606ba500d..2960acf01 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,24 +6,28 @@ import vuetify from 'vite-plugin-vuetify' const path = require('path') // eslint-disable-line @typescript-eslint/no-var-requires +// Check if we're running in Electron mode +const isElectron = process.env.ELECTRON === 'true' + export default defineConfig({ plugins: [ - electron({ - entry: 'electron/main.ts', - vite: { - build: { - outDir: 'dist/electron', + isElectron && + electron({ + entry: 'electron/main.ts', + vite: { + build: { + 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() - }, - }), + 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({ autoImport: true, @@ -35,7 +39,7 @@ export default defineConfig({ }, includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'masked-icon.svg'], }), - ], + ].filter(Boolean), define: { 'process.env': {} }, resolve: { alias: {