You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
3.0 KiB
84 lines
3.0 KiB
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import { resolve } from 'path'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import Components from 'unplugin-vue-components/vite'
|
|
import { TDesignResolver } from 'unplugin-vue-components/resolvers'
|
|
|
|
// Node 20.18 for Windows 缺少 getRandomValues,手动 polyfill
|
|
import crypto from 'node:crypto'
|
|
if (!globalThis.crypto) {
|
|
(globalThis as any).crypto = crypto
|
|
}
|
|
if (!(globalThis.crypto as any).getRandomValues) {
|
|
(globalThis.crypto as any).getRandomValues = (arr: Uint8Array) => crypto.randomFillSync(arr)
|
|
}
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
// TDesign 按需自动引入
|
|
AutoImport({
|
|
resolvers: [TDesignResolver({ library: 'vue-next' })],
|
|
}),
|
|
Components({
|
|
resolvers: [TDesignResolver({ library: 'vue-next' })],
|
|
}),
|
|
],
|
|
// 同源部署:资源使用绝对路径 /
|
|
base: '/',
|
|
resolve: {
|
|
alias: {
|
|
'@': resolve(__dirname, 'src'),
|
|
},
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
assetsDir: 'assets',
|
|
sourcemap: false, // 生产环境不需要 sourcemap,加速构建
|
|
minify: 'esbuild', // esbuild 比 terser 快 20-40 倍
|
|
reportCompressedSize: false, // 跳过压缩体积报告,省 1~3s
|
|
rollupOptions: {
|
|
output: {
|
|
// 拆出独立 chunk,浏览器可长期缓存
|
|
manualChunks(id) {
|
|
if (id.includes('@tdesign-vue-next/chat')) return 'tdesign-chat'
|
|
if (id.includes('tdesign-web-components')) return 'tdesign-web-components'
|
|
if (id.includes('tdesign-vue-next')) return 'tdesign'
|
|
// 注意:mermaid 不再单独拆包;引入 tdesign-web-components 后,
|
|
// mermaid 同时被 PipelineFlow 与 web-components 引用,单独拆出会导致循环 chunk 警告。
|
|
},
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
proxy: {
|
|
// 开发阶段:API 请求代理到 Spring Boot 后端 9090
|
|
'/ai': 'http://localhost:9090',
|
|
'/auth': 'http://localhost:9090',
|
|
'/category': 'http://localhost:9090',
|
|
'/conversation': 'http://localhost:9090',
|
|
'/dashboard': 'http://localhost:9090',
|
|
'/document': 'http://localhost:9090',
|
|
'/faq': 'http://localhost:9090',
|
|
'/feedback': 'http://localhost:9090',
|
|
'/model-config': 'http://localhost:9090',
|
|
'/sensitive-word': 'http://localhost:9090',
|
|
'/upload': 'http://localhost:9090',
|
|
'/api-key': 'http://localhost:9090',
|
|
'/webhook': 'http://localhost:9090',
|
|
'/mcp-server': 'http://localhost:9090',
|
|
'/system-config': 'http://localhost:9090',
|
|
'/sys-user': 'http://localhost:9090',
|
|
'/sys-role': 'http://localhost:9090',
|
|
'/tag': 'http://localhost:9090',
|
|
'/open-api': 'http://localhost:9090',
|
|
'/sdk': 'http://localhost:9090',
|
|
'/doc.html': 'http://localhost:9090',
|
|
'/swagger-ui': 'http://localhost:9090',
|
|
'/v3': 'http://localhost:9090',
|
|
'/webjars': 'http://localhost:9090',
|
|
},
|
|
},
|
|
})
|