Files
TERES_web_frontend/vite.config.ts
guangfei.zhao ef0a99ea30 refactor(build): improve caching strategy with content hashing
feat(header): add translation support for menu items
fix(models): enhance model factory handling with proper dialogs
2025-10-29 10:29:08 +08:00

56 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import svgr from "vite-plugin-svgr";
// 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'],
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
})