import { fileURLToPath } from 'node:url'; import react from '@vitejs/plugin-react'; import { defineConfig } from 'vite'; export default defineConfig(({ mode }) => ({ plugins: [react()], build: { rollupOptions: { output: { // Framework code changes far less often than app code; splitting keeps // the vendor chunk cacheable across releases instead of one big bundle. manualChunks(id) { if (id.includes('node_modules')) return 'vendor'; return undefined; }, }, }, }, resolve: { alias: mode === 'test' ? [ { find: /^animal-island-ui$/u, replacement: fileURLToPath( new URL('./node_modules/animal-island-ui/dist/cjs/index.cjs', import.meta.url), ), }, ] : [], }, }));