73 lines
2.6 KiB
TypeScript
73 lines
2.6 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import path from 'path';
|
|
import { loadDeploymentYaml } from '@lilith/service-registry/deployment';
|
|
import { versionPlugin } from '@lilith/vite-version-plugin';
|
|
|
|
// Resolve admin service addresses from the canonical services.yaml — single source of truth.
|
|
const projectRoot = path.resolve(__dirname, '../../../..');
|
|
const adminDeployment = loadDeploymentYaml(path.join(projectRoot, 'deployments/@domains/quinn.admin'));
|
|
const adminApiService = adminDeployment.services.find((s) => s.id === 'api');
|
|
const adminFrontendService = adminDeployment.services.find((s) => s.id === 'frontend');
|
|
const adminDeploymentDev = adminDeployment.deployments?.dev as { domain?: string } | undefined;
|
|
const adminApiPort = adminApiService?.port ?? 3023;
|
|
const adminFrontendPort = adminFrontendService?.port ?? 5121;
|
|
|
|
// Dev: localhost URLs derived from services.yaml ports
|
|
// Prod: https domain from services.yaml deployments.production.domain
|
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
const adminApiUrl = isProduction
|
|
? `https://${adminDeployment.deployment.domain}`
|
|
: `http://localhost:${adminApiPort}`;
|
|
const adminUrl = isProduction
|
|
? `https://${adminDeployment.deployment.domain}`
|
|
: adminDeploymentDev?.domain != null
|
|
? `https://${adminDeploymentDev.domain}`
|
|
: `http://localhost:${adminFrontendPort}`;
|
|
|
|
export default defineConfig({
|
|
define: {
|
|
// Admin service addresses — injected from deployments/@domains/quinn.admin/services.yaml
|
|
'import.meta.env.VITE_ADMIN_API_URL': JSON.stringify(adminApiUrl),
|
|
'import.meta.env.VITE_ADMIN_URL': JSON.stringify(adminUrl),
|
|
},
|
|
plugins: [
|
|
react(),
|
|
versionPlugin({ appName: 'Quinn Analytics', versionFile: path.resolve(__dirname, '../../../../VERSION.txt') }),
|
|
],
|
|
base: '/',
|
|
server: {
|
|
port: 5122,
|
|
strictPort: true,
|
|
allowedHosts: ['.local'],
|
|
proxy: {
|
|
'/api': {
|
|
target: `http://localhost:4005`,
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
resolve: {
|
|
dedupe: ['styled-components', 'react', 'react-dom'],
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
'styled-components': path.resolve(__dirname, 'node_modules/styled-components'),
|
|
},
|
|
},
|
|
optimizeDeps: {
|
|
exclude: ['@lilith/ui-animated'],
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
sourcemap: true,
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
'vendor-react': ['react', 'react-dom', 'react-router-dom'],
|
|
'vendor-charts': ['recharts'],
|
|
'vendor-maps': ['react-simple-maps', 'topojson-client'],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|