-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
116 lines (114 loc) · 4.53 KB
/
vite.config.ts
File metadata and controls
116 lines (114 loc) · 4.53 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { wayfinder } from '@laravel/vite-plugin-wayfinder';
import tailwindcss from '@tailwindcss/vite';
import react from '@vitejs/plugin-react';
import laravel from 'laravel-vite-plugin';
import { defineConfig } from 'vitest/config';
export default defineConfig(() => {
const viteServerPort = parseInt(process.env.VITE_SERVER_PORT ?? '5173');
return {
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.tsx', 'resources/js/swagger.tsx', 'resources/js/pages/dashboard.tsx'],
ssr: 'resources/js/ssr.tsx',
refresh: true,
}),
react(),
tailwindcss(),
wayfinder({
formVariants: true,
}),
],
build: {
outDir: 'public/build',
assetsDir: 'assets',
sourcemap: false,
rollupOptions: {
output: {
manualChunks: undefined
}
}
},
define: {
global: 'globalThis',
},
resolve: {
alias: {
'@': '/resources/js',
'@data': '/resources/data',
'@tests': '/tests',
'@test-helpers': '/tests/vitest/test-helpers',
},
},
optimizeDeps: {
include: ['react', 'react-dom', 'swagger-ui-react'],
},
server: {
warmup: {
clientFiles: ['resources/js/swagger.tsx'],
},
// Docker development configuration
host: '0.0.0.0',
port: viteServerPort,
strictPort: true,
// Configure origin for Docker/Traefik setup
origin: process.env.VITE_DEV_SERVER_URL || undefined,
// Allow all hosts in development (required for Docker networking)
allowedHosts: true,
hmr: {
// When running in Docker with Traefik, HMR uses WebSocket through the proxy
protocol: 'wss',
host: process.env.VITE_HMR_HOST || 'localhost',
// IMPORTANT:
// - `port` is the *Vite server* port (inside Docker / behind Traefik)
// - `clientPort` is the *public proxy* port the browser connects to
// If `port` != Vite's server port, Vite starts a separate WS server and HMR breaks.
port: viteServerPort,
clientPort: process.env.VITE_HMR_PORT ? parseInt(process.env.VITE_HMR_PORT) : 3333,
},
cors: true,
watch: {
// Use polling for file changes in Docker volumes (Windows compatibility)
usePolling: process.env.VITE_USE_POLLING === 'true',
},
},
test: {
environment: 'jsdom',
globals: true,
setupFiles: './vitest.setup.ts',
include: ['tests/vitest/**/*.{test,spec}.{js,ts,jsx,tsx}'],
testTimeout: 10000, // Increased from default 5000ms for controlled vocabulary (GCMD) loading in DataCiteForm initialization
env: {
VITE_APP_URL: '',
APP_URL: '',
},
coverage: {
provider: 'v8' as const,
reporter: ['text', 'json-summary', 'lcov'],
reportsDirectory: 'coverage',
include: ['resources/js/**/*.{js,ts,jsx,tsx}'],
exclude: [
// Test files and mocks
'tests/vitest/**',
'resources/js/**/__mocks__/**',
// Auto-generated Wayfinder files (Laravel route helpers)
'resources/js/actions/**',
'resources/js/routes/**',
'resources/js/routes.ts',
// Application entry points (not unit-testable)
'resources/js/app.tsx',
'resources/js/ssr.tsx',
'resources/js/swagger.tsx',
// Third-party UI library (shadcn/ui components)
'resources/js/components/ui/**',
// Pure type definition files (no executable code)
'resources/js/**/*.d.ts',
'resources/js/types/affiliations.ts',
'resources/js/types/docs.ts',
'resources/js/types/old-datasets.ts',
'resources/js/types/portal.ts',
'resources/js/types/resources.ts',
],
},
},
};
});