2025-08-13 03:21:24 +08:00
|
|
|
import tailwindcss from '@tailwindcss/vite';
|
|
|
|
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
|
|
|
|
import viteReact from '@vitejs/plugin-react';
|
|
|
|
import { defineConfig } from 'vite';
|
2025-08-13 04:07:06 +08:00
|
|
|
import checker from 'vite-plugin-checker';
|
2025-08-13 03:21:24 +08:00
|
|
|
import viteTsConfigPaths from 'vite-tsconfig-paths';
|
2025-08-12 11:28:36 +08:00
|
|
|
|
|
|
|
const config = defineConfig({
|
2025-08-14 03:52:10 +08:00
|
|
|
server: { port: 3000 },
|
2025-08-12 11:28:36 +08:00
|
|
|
plugins: [
|
|
|
|
// this is the plugin that enables path aliases
|
2025-08-14 03:52:10 +08:00
|
|
|
viteTsConfigPaths({ projects: ['./tsconfig.json'] }),
|
2025-08-12 11:28:36 +08:00
|
|
|
tailwindcss(),
|
2025-08-14 03:52:10 +08:00
|
|
|
tanstackStart({ customViteReactPlugin: true }),
|
2025-08-13 04:07:06 +08:00
|
|
|
viteReact(),
|
2025-08-14 06:08:21 +08:00
|
|
|
!process.env.VITEST && process.env.NODE_ENV !== 'development'
|
2025-08-13 12:37:41 +08:00
|
|
|
? checker({
|
|
|
|
typescript: true,
|
|
|
|
biome: true,
|
|
|
|
})
|
|
|
|
: undefined,
|
2025-08-13 04:07:06 +08:00
|
|
|
],
|
2025-08-14 03:52:10 +08:00
|
|
|
build: {
|
|
|
|
rollupOptions: {
|
2025-08-14 05:16:33 +08:00
|
|
|
// Exclude test and stories files from build
|
|
|
|
external: (id) => {
|
|
|
|
// Exclude .test and .stories files
|
|
|
|
return /\.(test|stories)\.(js|ts|jsx|tsx)$/.test(id);
|
|
|
|
},
|
2025-08-14 03:52:10 +08:00
|
|
|
output: {
|
|
|
|
// Force lodash and lodash-es into a dedicated vendor chunk
|
|
|
|
manualChunks(id) {
|
|
|
|
if (id.includes('node_modules/lodash')) {
|
|
|
|
return 'vendor-lodash';
|
|
|
|
}
|
|
|
|
if (id.includes('node_modules/lodash-es')) {
|
|
|
|
return 'vendor-lodash';
|
|
|
|
}
|
2025-08-14 04:19:50 +08:00
|
|
|
// Move supabase modules to their own chunk
|
|
|
|
if (id.includes('node_modules/@supabase')) {
|
|
|
|
return 'vendor-supabase';
|
|
|
|
}
|
2025-08-14 04:24:13 +08:00
|
|
|
|
|
|
|
if (id.includes('components/ui/icons')) {
|
|
|
|
return 'vendor-icons';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id.includes('components/ui')) {
|
|
|
|
return 'vendor-ui';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id.includes('zod')) {
|
|
|
|
return 'vendor-zod';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id.includes('@tanstack')) {
|
|
|
|
return 'vendor-tanstack';
|
|
|
|
}
|
2025-08-14 03:52:10 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2025-08-12 11:28:36 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
export default config;
|