Files
TERES_web_frontend/vite.config.ts

70 lines
1.9 KiB
TypeScript
Raw Normal View History

2025-10-09 15:59:50 +08:00
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import svgr from "vite-plugin-svgr";
2025-10-09 15:59:50 +08:00
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
svgr({
svgrOptions: {
icon: true,
prettier: true,
},
}),
],
build: {
rollupOptions: {
output: {
// 优化缓存策略,使用内容哈希,启用长期缓存
entryFileNames: 'assets/[name]-[hash].js',
chunkFileNames: 'assets/[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash].[ext]',
manualChunks: (id) => {
// SVG 文件分割策略
if (id.includes('.svg') && id.includes('?react')) {
// 排除 chunk-method 文件夹的 SVG
if (id.includes('/chunk-method/')) {
// 不打包 chunk-method 的 SVG让它们保持为独立的资源文件
return undefined;
}
// 其他 SVG 文件正常分割
if (id.includes('/llm/')) {
return 'svg-llm';
} else if (id.includes('/file-icon/')) {
return 'svg-file';
} else {
return 'svg-common';
}
}
}
}
},
},
server: {
host: '0.0.0.0',
allowedHosts: ['154.9.253.114', 'localhost', 'teres.deep-pilot.chat'],
proxy: {
// 将 /ragflow 下的所有请求代理到 Umi 开发服务器(默认 9222
'/ragflow': {
target: 'http://localhost:9222',
changeOrigin: true,
ws: true,
// 不重写路径,保持 /ragflow 前缀用于 Umi base/publicPath
},
'/__umi': {
target: 'http://localhost:9222',
changeOrigin: true,
ws: true,
},
}
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
2025-10-09 15:59:50 +08:00
})