experiment(electron): different vite build script for web application

This commit is contained in:
Matthew Raymer
2025-05-29 13:09:36 +00:00
parent fb8d1cb8b2
commit d9895086e6

View File

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