/** * 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), }, }); });