mirror of https://github.com/buster-so/buster.git
67 lines
2.1 KiB
TypeScript
67 lines
2.1 KiB
TypeScript
import tailwindcss from '@tailwindcss/vite';
|
|
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
|
|
import viteReact from '@vitejs/plugin-react';
|
|
import { defineConfig } from 'vite';
|
|
import checker from 'vite-plugin-checker';
|
|
import viteTsConfigPaths from 'vite-tsconfig-paths';
|
|
|
|
const config = defineConfig(({ command, mode }) => {
|
|
const isBuild = command === 'build';
|
|
const isProduction = mode === 'production';
|
|
const isTypecheck = process.argv.includes('--typecheck') || process.env.TYPECHECK === 'true';
|
|
const useChecker = !process.env.VITEST && isBuild;
|
|
|
|
return {
|
|
server: { port: 3000 },
|
|
plugins: [
|
|
// this is the plugin that enables path aliases
|
|
viteTsConfigPaths({ projects: ['./tsconfig.json'] }),
|
|
tailwindcss(),
|
|
tanstackStart({ customViteReactPlugin: true, target: 'bun' }),
|
|
viteReact(),
|
|
useChecker
|
|
? checker({
|
|
typescript: isTypecheck,
|
|
biome: isProduction,
|
|
})
|
|
: undefined,
|
|
],
|
|
build: {
|
|
chunkSizeWarningLimit: 650,
|
|
rollupOptions: {
|
|
// Exclude test and stories files from build
|
|
external: (id) => {
|
|
// Exclude .test and .stories files
|
|
return /\.(test|stories)\.(js|ts|jsx|tsx)$/.test(id);
|
|
},
|
|
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';
|
|
}
|
|
// // Move supabase modules to their own chunk
|
|
if (id.includes('node_modules/@supabase')) {
|
|
return 'vendor-supabase';
|
|
}
|
|
if (id.includes('zod')) {
|
|
return 'vendor-zod';
|
|
}
|
|
if (id.includes('monaco-editor')) {
|
|
return 'vendor-monaco-editor';
|
|
}
|
|
if (id.includes('@tanstack')) {
|
|
return 'vendor-tanstack';
|
|
}
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
});
|
|
|
|
export default config;
|