-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
84 lines (76 loc) · 2.46 KB
/
vite.config.ts
File metadata and controls
84 lines (76 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/// <reference types="vitest" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
// https://vitejs.dev/config/
// Note: CJS deprecation warning is informational and doesn't affect functionality.
// It occurs when dependencies use the legacy CommonJS Vite API instead of ES modules.
// This is expected during the migration period from CRA to Vite.
export default defineConfig({
plugins: [react()],
// Path aliases to match tsconfig paths
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
// Development server configuration
server: {
port: 3000,
host: true, // Allow external connections
open: false, // Don't auto-open browser (matches BROWSER=none from CRA)
},
// Build configuration
build: {
outDir: 'build', // Keep same output directory as CRA
sourcemap: true,
// Optimize chunk splitting for better caching
rollupOptions: {
output: {
manualChunks: {
vendor: ['react', 'react-dom'],
router: ['react-router-dom'],
query: ['@tanstack/react-query'],
ui: [
'@radix-ui/react-accordion',
'@radix-ui/react-alert-dialog',
'@radix-ui/react-avatar',
],
},
},
},
},
// Environment variables configuration
// Vite automatically loads .env files and exposes variables prefixed with VITE_
envPrefix: 'VITE_',
// CSS configuration
css: {
postcss: './postcss.config.js', // Use existing PostCSS config
},
// Vitest test configuration
test: {
globals: true, // so you can use 'describe', 'it', 'expect' without importing
environment: 'jsdom', // simulates browser for React components
setupFiles: ['./vitest.setup.ts'], // path to setup file
coverage: {
provider: 'v8',
reporter: ['lcov', 'text', 'html'],
reportsDirectory: 'coverage',
include: ['src/**/*.{ts,tsx}'], // include all source files
exclude: [
'src/**/*.spec.{ts,tsx}',
'src/**/*.test.{ts,tsx}',
'src/**/*.model.ts',
'src/**/*.module.ts',
'src/**/*.d.ts',
'src/stories/**',
'src/assets/**',
'node_modules/**',
],
},
include: ['**/*.spec.{ts,tsx}'],
// Mock file imports (images, CSS, etc.)
// server.deps.inline removed (not needed unless you have ESM/CJS issues)
},
// optimizeDeps.include removed (not needed unless you have pre-bundling issues)
});