Files
llm-in-text/vite.config.js
ydy0615 eb6e8bbfff refactor(config): use Vite proxy for API requests and change backend port
- Configure Vite dev server to proxy /v1 requests to backend
- Change backend port from 8000 to 8001
- Simplify API URLs to relative paths instead of absolute localhost URLs
- Increase debounce delay from 500ms to 1000ms for better stability
- Update README documentation to reflect all changes
2026-02-15 23:23:00 +08:00

60 lines
1.7 KiB
JavaScript

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
server: {
host: true,
port: 5173,
proxy: {
'/v1': {
target: 'http://localhost:8001',
changeOrigin: true
}
}
},
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (!id.includes('node_modules')) return
const modulePath = id.split('node_modules/')[1]
const segments = modulePath.split('/')
const packageName = segments[0].startsWith('@')
? `${segments[0]}/${segments[1]}`
: segments[0]
if (packageName.startsWith('@milkdown')) return 'milkdown'
if (packageName.startsWith('prosemirror')) return 'prosemirror'
if (packageName.startsWith('@codemirror')) {
const langMatch = modulePath.match(/@codemirror\/lang-([^/]+)/)
if (langMatch) return `cm-lang-${langMatch[1]}`
return `cm-${segments[1]}`
}
if (packageName === 'refractor') {
const langMatch = modulePath.match(/refractor\/lang\/([^./]+)/)
if (langMatch) return `refractor-lang-${langMatch[1]}`
return 'refractor-core'
}
if (packageName.startsWith('katex')) return 'katex'
if (packageName.startsWith('markdown-it')) return 'markdown'
if (packageName === 'vue' || packageName.startsWith('@vue')) return 'vue'
return `vendor-${packageName.replace('@', '').replace('/', '-')}`
}
}
}
},
optimizeDeps: {
include: [
'@milkdown/crepe',
'@milkdown/vue',
'@milkdown/kit'
]
}
})