35 lines
902 B
JavaScript
35 lines
902 B
JavaScript
import { defineConfig, loadEnv } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import tailwindcss from '@tailwindcss/vite';
|
|
import path from 'path';
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, path.resolve(__dirname, '..'), '');
|
|
const backendPort = env.FASTAPI_PORT || 8000;
|
|
const backendHost = env.FASTAPI_HOST === '0.0.0.0' ? 'localhost' : (env.FASTAPI_HOST || 'localhost');
|
|
const frontendPort = parseInt(env.VITE_PORT || '5173', 10);
|
|
|
|
return {
|
|
plugins: [
|
|
react(),
|
|
tailwindcss()
|
|
],
|
|
server: {
|
|
port: frontendPort,
|
|
host: true,
|
|
proxy: {
|
|
'/api': {
|
|
target: `http://${backendHost}:${backendPort}`,
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
test: {
|
|
globals: true,
|
|
environment: 'jsdom',
|
|
setupFiles: './src/setupTests.js'
|
|
}
|
|
};
|
|
});
|