2025-12-13 02:34:34 +00:00
|
|
|
/// <reference types="vitest" />
|
2025-12-03 21:56:50 +00:00
|
|
|
import { defineConfig, type Plugin } from 'vite'
|
|
|
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
|
import path from 'path'
|
|
|
|
|
import { visualizer } from 'rollup-plugin-visualizer'
|
|
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
|
|
|
const isProduction = mode === 'production'
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
plugins: [
|
|
|
|
|
react(),
|
|
|
|
|
// Bundle analyzer for production builds
|
|
|
|
|
(isProduction && visualizer({
|
|
|
|
|
filename: 'dist/bundle-analysis.html',
|
|
|
|
|
open: false,
|
|
|
|
|
gzipSize: true,
|
|
|
|
|
brotliSize: true,
|
|
|
|
|
})) as Plugin,
|
|
|
|
|
].filter(Boolean),
|
2025-12-13 02:34:34 +00:00
|
|
|
test: {
|
|
|
|
|
globals: true,
|
|
|
|
|
environment: 'jsdom',
|
|
|
|
|
setupFiles: './src/setupTests.ts',
|
|
|
|
|
css: true,
|
|
|
|
|
},
|
2025-12-03 21:56:50 +00:00
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'@': path.resolve(__dirname, './src'),
|
|
|
|
|
'@components': path.resolve(__dirname, './src/components'),
|
|
|
|
|
'@features': path.resolve(__dirname, './src/features'),
|
|
|
|
|
'@services': path.resolve(__dirname, './src/services'),
|
|
|
|
|
'@hooks': path.resolve(__dirname, './src/hooks'),
|
|
|
|
|
'@utils': path.resolve(__dirname, './src/utils'),
|
|
|
|
|
'@types': path.resolve(__dirname, './src/types'),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
server: {
|
2025-12-26 20:34:22 +00:00
|
|
|
port: 5173,
|
2026-01-29 22:22:32 +00:00
|
|
|
host: true,
|
|
|
|
|
// P2.1: Proxy API requests to backend in development
|
|
|
|
|
// This eliminates CORS issues in dev by making all requests same-origin
|
|
|
|
|
proxy: {
|
|
|
|
|
'/api': {
|
|
|
|
|
target: 'http://localhost:8080',
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
secure: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-12-03 21:56:50 +00:00
|
|
|
},
|
|
|
|
|
build: {
|
2026-01-25 11:33:46 +00:00
|
|
|
outDir: 'dist_verification',
|
|
|
|
|
sourcemap: isProduction ? 'hidden' : true,
|
|
|
|
|
target: 'esnext',
|
2025-12-03 21:56:50 +00:00
|
|
|
minify: 'esbuild',
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
output: {
|
2026-01-07 10:15:48 +00:00
|
|
|
manualChunks: (id) => {
|
2026-01-25 11:33:46 +00:00
|
|
|
// Core Vendors
|
|
|
|
|
if (id.includes('node_modules/react/') ||
|
|
|
|
|
id.includes('node_modules/react-dom/') ||
|
|
|
|
|
id.includes('node_modules/react/jsx-runtime')) {
|
|
|
|
|
return 'vendor-react';
|
|
|
|
|
}
|
|
|
|
|
if (id.includes('node_modules')) {
|
|
|
|
|
if (id.includes('react-router')) return 'vendor-router';
|
|
|
|
|
if (id.includes('@tanstack')) return 'vendor-tanstack';
|
|
|
|
|
if (id.includes('lucide-react')) return 'vendor-icons';
|
|
|
|
|
if (id.includes('date-fns')) return 'vendor-utils';
|
|
|
|
|
if (id.includes('zod')) return 'vendor-utils';
|
|
|
|
|
return 'vendor'; // Default vendor chunk
|
2026-01-15 18:26:53 +00:00
|
|
|
}
|
2025-12-03 21:56:50 +00:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
chunkSizeWarningLimit: 1000,
|
|
|
|
|
},
|
2026-01-25 11:33:46 +00:00
|
|
|
// Standard optimization settings usually work best
|
2025-12-03 21:56:50 +00:00
|
|
|
optimizeDeps: {
|
2026-01-25 11:33:46 +00:00
|
|
|
include: ['react', 'react-dom']
|
2025-12-03 21:56:50 +00:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|