import { fileURLToPath, URL } from 'node:url' import react from '@vitejs/plugin-react' import { defineConfig } from 'vite' // https://vite.dev/config/ export default defineConfig({ plugins: [react()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), }, }, server: { port: 5173, open: false, }, build: { outDir: 'dist', sourcemap: false, // antd 依赖本身较大,单独成包后放宽此告警阈值 chunkSizeWarningLimit: 700, // 把体积较大的第三方依赖拆成独立 chunk,便于长期缓存 rolldownOptions: { output: { codeSplitting: { groups: [ { name: 'react-vendor', test: /[\\/]node_modules[\\/](react|react-dom|scheduler)[\\/]/, }, { name: 'antd-vendor', test: /[\\/]node_modules[\\/](antd|@ant-design|@rc-component|rc-[^\\/]+)[\\/]/, }, ], }, }, }, }, })