mirror of
https://github.com/luckjiawei/podux.git
synced 2026-11-30 00:56:47 +00:00
66 lines
1.7 KiB
TypeScript
66 lines
1.7 KiB
TypeScript
import { defineConfig } from 'vite'
|
||
import react from '@vitejs/plugin-react'
|
||
import tailwindcss from '@tailwindcss/vite'
|
||
|
||
// https://vite.dev/config/
|
||
export default defineConfig({
|
||
plugins: [react(), tailwindcss()],
|
||
server: {
|
||
host: '0.0.0.0',
|
||
proxy: {
|
||
'/api': {
|
||
target: 'http://127.0.0.1:8090',
|
||
changeOrigin: true,
|
||
}
|
||
}
|
||
},
|
||
build: {
|
||
// 代码分割优化
|
||
rollupOptions: {
|
||
output: {
|
||
manualChunks: {
|
||
// 将 React 相关库单独打包
|
||
'react-vendor': ['react', 'react-dom', 'react-router-dom'],
|
||
// UI 组件库单独打包
|
||
'ui-vendor': ['@radix-ui/themes', 'sonner', 'framer-motion'],
|
||
// 图表库单独打包
|
||
'chart-vendor': ['recharts'],
|
||
// 工具库单独打包
|
||
'utils-vendor': ['i18next', 'react-i18next', 'pocketbase'],
|
||
},
|
||
// 优化资源文件名
|
||
chunkFileNames: 'assets/js/[name]-[hash].js',
|
||
entryFileNames: 'assets/js/[name]-[hash].js',
|
||
assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
|
||
},
|
||
},
|
||
// 压缩优化
|
||
minify: 'terser',
|
||
terserOptions: {
|
||
compress: {
|
||
drop_console: true, // 移除 console
|
||
drop_debugger: true, // 移除 debugger
|
||
pure_funcs: ['console.log'], // 移除特定函数
|
||
},
|
||
},
|
||
// 启用 CSS 代码分割
|
||
cssCodeSplit: true,
|
||
// 设置 chunk 大小警告限制
|
||
chunkSizeWarningLimit: 600,
|
||
// 生成 sourcemap(生产环境可以设为 false)
|
||
sourcemap: false,
|
||
},
|
||
// 依赖优化
|
||
optimizeDeps: {
|
||
include: [
|
||
'react',
|
||
'react-dom',
|
||
'react-router-dom',
|
||
'@radix-ui/themes',
|
||
'pocketbase',
|
||
'i18next',
|
||
'react-i18next',
|
||
],
|
||
},
|
||
})
|