From d9895086e60cc7ac9473d8ca4de85550730fb95a Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Thu, 29 May 2025 13:09:36 +0000 Subject: [PATCH] experiment(electron): different vite build script for web application --- vite.config.app.electron.mts | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 vite.config.app.electron.mts diff --git a/vite.config.app.electron.mts b/vite.config.app.electron.mts new file mode 100644 index 00000000..d5399111 --- /dev/null +++ b/vite.config.app.electron.mts @@ -0,0 +1,42 @@ +/** + * vite.config.app.electron.mts + * + * Vite configuration for building the web application for Electron. + * This config outputs to 'dist/' (like the web build), sets VITE_PLATFORM to 'electron', + * and disables PWA plugins and web-only features. Use this when you want to package + * the web app for Electron but keep the output structure identical to the web build. + * + * Author: Matthew Raymer + */ + +import { defineConfig, mergeConfig } from 'vite'; +import { createBuildConfig } from './vite.config.common.mts'; +import { loadAppConfig } from './vite.config.utils.mts'; +import path from 'path'; + +export default defineConfig(async () => { + // Set mode to 'electron' for platform-specific config + const mode = 'electron'; + const baseConfig = await createBuildConfig(mode); + const appConfig = await loadAppConfig(); + + // Override build output directory to 'dist/' + const buildConfig = { + outDir: path.resolve(__dirname, 'dist'), + emptyOutDir: true, + rollupOptions: { + input: path.resolve(__dirname, 'index.html'), + }, + }; + + // No PWA plugins or web-only plugins for Electron + return mergeConfig(baseConfig, { + build: buildConfig, + plugins: [], + define: { + 'process.env.VITE_PLATFORM': JSON.stringify('electron'), + 'process.env.VITE_PWA_ENABLED': JSON.stringify(false), + 'process.env.VITE_DISABLE_PWA': JSON.stringify(true), + }, + }); +}); \ No newline at end of file