You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.0 KiB

import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
import vue from "@vitejs/plugin-vue";
import dotenv from "dotenv";
import { loadAppConfig } from "./vite.config.utils";
// Load environment variables from .env file
dotenv.config();
// Load application configuration
const appConfig = loadAppConfig();
export default defineConfig(({ mode }) => {
const isElectron = mode === "electron";
const isCapacitor = mode === "capacitor";
// Set output directory based on build mode
const outDir = isElectron
? "dist-electron"
: isCapacitor
? "dist-capacitor"
: "dist";
return {
base: isElectron ? "./" : "/",
server: {
port: process.env.VITE_PORT || 8080,
},
build: {
outDir, // Dynamically set output directory
},
plugins: [
vue(),
...(isElectron
? [] // Skip PWA for Electron builds
: [
VitePWA({
...appConfig.pwaConfig,
}),
]),
],
resolve: {
alias: appConfig.aliasConfig,
},
};
});