45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { defineConfig, loadEnv } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import tailwindcss from '@tailwindcss/vite';
|
|
import { fileURLToPath } from 'node:url';
|
|
export default defineConfig(({ mode }) => {
|
|
const env = { ...loadEnv(mode, '../..', ''), ...process.env };
|
|
return {
|
|
plugins: [
|
|
react(),
|
|
tailwindcss(),
|
|
{
|
|
name: 'server-boundary',
|
|
generateBundle() {
|
|
for (const id of this.getModuleIds())
|
|
if (
|
|
id.includes('@prisma') ||
|
|
id.includes('/packages/database/') ||
|
|
/\/node_modules\/(pg|pg-pool)\//.test(id)
|
|
)
|
|
this.error(`Server dependency in browser bundle: ${id}`);
|
|
},
|
|
},
|
|
],
|
|
resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } },
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks(id) {
|
|
if (/\/node_modules\/(react|react-dom|scheduler)\//.test(id)) return 'react-vendor';
|
|
if (/\/node_modules\/(zod|react-hook-form|@hookform)\//.test(id)) return 'forms';
|
|
if (id.includes('/@base-ui/') || id.includes('/@floating-ui/')) return 'primitives';
|
|
},
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
port: Number(env.WEB_PORT ?? 5173),
|
|
strictPort: true,
|
|
proxy: {
|
|
'/api': { target: `http://127.0.0.1:${env.API_PORT ?? 3001}`, changeOrigin: false },
|
|
},
|
|
},
|
|
};
|
|
});
|