import { defineConfig, loadEnv, type PluginOption } from 'vite' import react from '@vitejs/plugin-react' import tailwindcss from '@tailwindcss/vite' import path from 'path' import { fileURLToPath } from 'url' const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); export default defineConfig(({ mode }) => { const envDirectory = path.resolve(__dirname, '..'); const env = loadEnv(mode, envDirectory, ''); const backendTarget = env.VITE_API_TARGET; return { envDir: envDirectory, plugins: [ react() as PluginOption, tailwindcss() as PluginOption, ], server: { port: 6568, host: true, proxy: { '/api': { target: backendTarget, changeOrigin: true, secure: false, }, }, }, preview: { port: 6568, allowedHosts: true, }, } })