import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import path from 'path'; import fs from 'fs'; // Read the canonical version from /VERSION (repo root, mounted at /app/VERSION in Docker). // Falls back to the VITE_APP_VERSION env var so production Docker builds can pass it // as a build arg (--build-arg VITE_APP_VERSION=$(cat VERSION)) without needing the file. function readAppVersion(): string { try { return fs.readFileSync(path.resolve(__dirname, 'VERSION'), 'utf-8').trim(); } catch { return process.env.VITE_APP_VERSION ?? 'dev'; } } const APP_VERSION = readAppVersion(); export default defineConfig({ plugins: [react()], define: { // Injected at compile time — use __APP_VERSION__ anywhere in frontend source. __APP_VERSION__: JSON.stringify(APP_VERSION), }, resolve: { alias: { '@': path.resolve(__dirname, './src'), }, }, server: { allowedHosts: ['app.hoaledgeriq.com'], host: '0.0.0.0', port: 5173, proxy: { '/api': { target: 'http://backend:3000', changeOrigin: true, }, }, }, });