Lighthouse (production, default mobile 4x-CPU profile) scored Performance 33/100, dominated by one ~536-538 KB entry chunk that bundled every route's code regardless of which page a visitor landed on -- the "chunks are larger than 500 kB" Vite warning on every build this session. Converted every route except / and the 404 catch-all to React Router 8's native route.lazy (blocks navigation until the chunk is ready -- no separate Suspense fallback needed). AppShell/HomePage/NotFoundPage/ RequireAuth stay eager since they're needed on every load regardless. Result: main chunk 490.84 KB, no >500kB warning, one small chunk per route (LoginPage 1.4 KB, ThemesPage 15.5 KB, AccountPage 11 KB, etc.) loaded only when actually visited. Fixed a real race the lazy boundary exposed: /login and /register share an "Почта" field label, and during the chunk swap between them the old page can stay mounted a beat longer than before -- a test grabbing the field by label could land on the about-to-unmount one. Also bumped RTL's asyncUtilTimeout and vitest's testTimeout, since the route-transition + findBy chain didn't always land inside the old 1000/5000ms defaults under full parallel test-suite load. Claude-Session: https://claude.ai/code/session_01F1M1Jic1wTSn4igUENynmZ
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import tailwindcss from '@tailwindcss/vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { defineConfig } from 'vitest/config'
|
|
|
|
// Path aliases mirror tsconfig `paths` — register here once instead of writing `../../../` chains.
|
|
const src = fileURLToPath(new URL('./src', import.meta.url))
|
|
|
|
export default defineConfig({
|
|
plugins: [react(), tailwindcss()],
|
|
resolve: {
|
|
alias: {
|
|
'@shared': `${src}/shared`,
|
|
'@features': `${src}/features`,
|
|
'@pages': `${src}/pages`,
|
|
'@app': `${src}/app`,
|
|
'@test': `${src}/test`,
|
|
},
|
|
},
|
|
server: {
|
|
// Tests read the mod's theme presets (outside this package) to check the generated copy.
|
|
fs: process.env.VITEST ? { allow: ['.', '../mod/src/main/java/dev/loki/lovisual/features/theme/presets'] } : undefined,
|
|
// Same-origin in dev: the browser talks to /api, Vite forwards to the gateway.
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:8080',
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
|
// The refresh cookie is scoped to Path=/auth by the backend; in dev the
|
|
// browser sees it under /api/auth, so rewrite the path accordingly.
|
|
cookiePathRewrite: { '/auth': '/api/auth' },
|
|
},
|
|
},
|
|
},
|
|
test: {
|
|
environment: 'jsdom',
|
|
setupFiles: ['./src/test/setup.ts'],
|
|
css: false,
|
|
// Route pages now load via dynamic import() (src/app/routes.tsx); the default 5000ms
|
|
// per-test budget can be tight for a route-transition test under a loaded parallel run.
|
|
testTimeout: 10000,
|
|
},
|
|
})
|