32 lines
940 B
TypeScript
32 lines
940 B
TypeScript
import path from "path"
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
// Load env file from current directory, including those from process.env
|
|
const env = loadEnv(mode, process.cwd(), '');
|
|
|
|
// Prioritize the Docker-injected API_TARGET, fallback to local for dev
|
|
const apiTarget = env.API_TARGET || 'http://localhost:5001';
|
|
|
|
return {
|
|
plugins: [react(), tailwindcss()],
|
|
resolve: {
|
|
alias: {
|
|
"@": path.resolve(__dirname, "./src"),
|
|
},
|
|
},
|
|
server: {
|
|
host: true, // Needed for Docker to expose the port
|
|
proxy: {
|
|
'/api': {
|
|
target: apiTarget,
|
|
changeOrigin: true,
|
|
// If your Flask backend doesn't expect /api prefix, add rewrite:
|
|
// rewrite: (path) => path.replace(/^\/api/, '')
|
|
},
|
|
},
|
|
},
|
|
};
|
|
}) |