Files
bakery-ia/frontend/vite.config.ts

65 lines
2.1 KiB
TypeScript
Raw Normal View History

2025-08-28 10:41:04 +02:00
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
export default defineConfig({
plugins: [
react(),
2025-09-27 11:18:13 +02:00
// PWA plugin temporarily disabled to avoid service worker conflicts
// VitePWA can be re-enabled later for production PWA features
2025-08-28 10:41:04 +02:00
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@components': path.resolve(__dirname, './src/components'),
'@pages': path.resolve(__dirname, './src/pages'),
'@hooks': path.resolve(__dirname, './src/hooks'),
'@stores': path.resolve(__dirname, './src/stores'),
'@services': path.resolve(__dirname, './src/services'),
'@utils': path.resolve(__dirname, './src/utils'),
'@types': path.resolve(__dirname, './src/types'),
},
},
server: {
host: '0.0.0.0', // Important for Docker
port: 3000,
watch: {
usePolling: true, // Important for Docker file watching
// Ignore these directories to prevent "too many open files" error in Kubernetes
ignored: [
'**/node_modules/**',
'**/dist/**',
'**/.git/**',
'**/coverage/**',
'**/.cache/**',
],
2025-08-28 10:41:04 +02:00
},
proxy: {
'/api': {
target: process.env.VITE_API_URL !== undefined
2025-09-27 14:51:06 +02:00
? (process.env.VITE_API_URL || '') // Use value or empty string
: (process.env.NODE_ENV === 'development' && process.env.KUBERNETES_SERVICE_HOST
? 'http://gateway-service:8000' // Kubernetes internal service
: 'http://localhost:8000'), // Local development
2025-08-28 10:41:04 +02:00
changeOrigin: true,
2025-09-27 12:10:43 +02:00
rewrite: (path) => path.replace(/^\/api/, ''),
2025-08-28 10:41:04 +02:00
},
},
},
build: {
outDir: 'dist',
sourcemap: true,
rollupOptions: {
external: ['/runtime-config.js'], // Externalize runtime config to avoid bundling
2025-08-28 10:41:04 +02:00
output: {
manualChunks: {
vendor: ['react', 'react-dom', 'react-router-dom'],
ui: ['@radix-ui/react-dialog', '@radix-ui/react-dropdown-menu'],
charts: ['recharts'],
forms: ['react-hook-form', 'zod'],
},
},
},
},
2025-09-27 14:51:06 +02:00
});