41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { defineConfig, loadEnv } from "vite";
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), "");
|
|
return {
|
|
plugins: [react()],
|
|
build: {
|
|
// antd 单包本身较大,拆包后按组报告即可
|
|
chunkSizeWarningLimit: 1000,
|
|
rolldownOptions: {
|
|
output: {
|
|
// 框架 / 组件库 / 公式引擎拆包,业务代码更新时不失效缓存
|
|
advancedChunks: {
|
|
groups: [
|
|
{
|
|
name: "react",
|
|
test: /node_modules[\\/](react|react-dom|scheduler)[\\/]/,
|
|
},
|
|
{
|
|
name: "antd",
|
|
test: /node_modules[\\/](antd|@ant-design)[\\/]/,
|
|
},
|
|
{ name: "katex", test: /node_modules[\\/]katex[\\/]/ },
|
|
],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
proxy: {
|
|
"/api": {
|
|
target: env.VITE_API_PROXY || "http://localhost:8000",
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
});
|