2025-10-09 15:59:50 +08:00
|
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
|
import react from '@vitejs/plugin-react'
|
2025-10-10 15:09:04 +08:00
|
|
|
|
import path from 'path'
|
2025-10-21 16:48:48 +08:00
|
|
|
|
import svgr from "vite-plugin-svgr";
|
2025-10-09 15:59:50 +08:00
|
|
|
|
|
|
|
|
|
|
// https://vite.dev/config/
|
|
|
|
|
|
export default defineConfig({
|
2025-10-21 18:21:48 +08:00
|
|
|
|
plugins: [
|
|
|
|
|
|
react(),
|
|
|
|
|
|
svgr({
|
|
|
|
|
|
svgrOptions: {
|
|
|
|
|
|
icon: true,
|
|
|
|
|
|
prettier: true,
|
2025-10-28 15:28:56 +08:00
|
|
|
|
},
|
|
|
|
|
|
}),
|
2025-10-21 18:21:48 +08:00
|
|
|
|
],
|
2025-10-28 15:28:56 +08:00
|
|
|
|
build: {
|
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
|
output: {
|
2025-10-29 10:29:08 +08:00
|
|
|
|
// 优化缓存策略,使用内容哈希,启用长期缓存
|
|
|
|
|
|
entryFileNames: 'assets/[name]-[hash].js',
|
|
|
|
|
|
chunkFileNames: 'assets/[name]-[hash].js',
|
|
|
|
|
|
assetFileNames: 'assets/[name]-[hash].[ext]',
|
2025-10-28 15:28:56 +08:00
|
|
|
|
manualChunks: (id) => {
|
2025-10-29 10:29:08 +08:00
|
|
|
|
// SVG 文件分割策略
|
2025-10-28 15:28:56 +08:00
|
|
|
|
if (id.includes('.svg') && id.includes('?react')) {
|
2025-10-29 10:29:08 +08:00
|
|
|
|
// 排除 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';
|
|
|
|
|
|
}
|
2025-10-28 15:28:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-29 10:29:08 +08:00
|
|
|
|
},
|
2025-10-28 15:28:56 +08:00
|
|
|
|
},
|
2025-10-27 15:09:18 +08:00
|
|
|
|
server: {
|
|
|
|
|
|
host: '0.0.0.0',
|
|
|
|
|
|
allowedHosts: ['154.9.253.114', 'localhost', 'teres.deep-pilot.chat'],
|
2025-11-10 11:09:22 +08:00
|
|
|
|
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,
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
2025-10-27 15:09:18 +08:00
|
|
|
|
},
|
2025-10-10 15:09:04 +08:00
|
|
|
|
resolve: {
|
|
|
|
|
|
alias: {
|
|
|
|
|
|
'@': path.resolve(__dirname, './src'),
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2025-10-09 15:59:50 +08:00
|
|
|
|
})
|