42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
import { defineConfig } from 'vite'
|
||
import react from '@vitejs/plugin-react'
|
||
import path from 'path'
|
||
|
||
// https://vitejs.dev/config/
|
||
export default defineConfig({
|
||
plugins: [react()],
|
||
resolve: {
|
||
alias: {
|
||
'@': path.resolve(__dirname, './src'),
|
||
},
|
||
},
|
||
server: {
|
||
host: '0.0.0.0',
|
||
port: 5173,
|
||
open: true,
|
||
proxy: {
|
||
// 代理API请求到后端
|
||
'/api': {
|
||
target: 'http://localhost:8000',
|
||
changeOrigin: true,
|
||
},
|
||
},
|
||
},
|
||
build: {
|
||
outDir: 'dist',
|
||
sourcemap: false,
|
||
chunkSizeWarningLimit: 900,
|
||
rollupOptions: {
|
||
output: {
|
||
// 只把"几乎每个页面都要用"的基础库固定成独立 chunk,提升浏览器缓存命中;
|
||
// 编辑器(bytemd/codemirror)、PDF(pdfjs)、markdown 等重依赖交给路由懒加载自动分包,
|
||
// 手工分组反而会让它们进入首屏 modulepreload 列表。
|
||
manualChunks: {
|
||
react: ['react', 'react-dom', 'react-router-dom'],
|
||
antd: ['antd', '@ant-design/icons', 'antd-img-crop'],
|
||
},
|
||
},
|
||
},
|
||
},
|
||
})
|