2026-04-11 15:59:14 +08:00
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
|
|
import type { ProxyOptions } from 'vite'
|
|
|
|
|
import { resolve } from 'path'
|
2026-04-16 13:51:42 +08:00
|
|
|
import pkg from './package.json'
|
2026-04-11 15:59:14 +08:00
|
|
|
|
2026-04-15 16:36:04 +08:00
|
|
|
const BACKEND = 'http://127.0.0.1:8648'
|
|
|
|
|
|
2026-04-11 15:59:14 +08:00
|
|
|
function createProxyConfig(): ProxyOptions {
|
|
|
|
|
return {
|
2026-04-15 16:36:04 +08:00
|
|
|
target: BACKEND,
|
2026-04-11 15:59:14 +08:00
|
|
|
changeOrigin: true,
|
|
|
|
|
configure: (proxy) => {
|
|
|
|
|
proxy.on('proxyReq', (proxyReq) => {
|
|
|
|
|
proxyReq.removeHeader('origin')
|
|
|
|
|
proxyReq.removeHeader('referer')
|
|
|
|
|
})
|
|
|
|
|
proxy.on('proxyRes', (proxyRes) => {
|
|
|
|
|
proxyRes.headers['cache-control'] = 'no-cache'
|
|
|
|
|
proxyRes.headers['x-accel-buffering'] = 'no'
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default defineConfig({
|
2026-04-16 08:38:18 +08:00
|
|
|
root: 'packages/client',
|
2026-04-11 21:33:04 +08:00
|
|
|
plugins: [vue()],
|
2026-04-16 13:51:42 +08:00
|
|
|
define: {
|
|
|
|
|
__APP_VERSION__: JSON.stringify(pkg.version),
|
|
|
|
|
},
|
2026-04-11 15:59:14 +08:00
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
2026-04-16 08:38:18 +08:00
|
|
|
'@': resolve(__dirname, 'packages/client/src'),
|
2026-04-11 15:59:14 +08:00
|
|
|
},
|
|
|
|
|
},
|
2026-04-16 08:38:18 +08:00
|
|
|
build: {
|
|
|
|
|
outDir: '../../dist/client',
|
|
|
|
|
emptyOutDir: true,
|
|
|
|
|
},
|
2026-04-23 12:09:39 +08:00
|
|
|
optimizeDeps: {
|
|
|
|
|
include: ['monaco-editor'],
|
|
|
|
|
},
|
2026-04-11 15:59:14 +08:00
|
|
|
server: {
|
|
|
|
|
proxy: {
|
|
|
|
|
'/api': createProxyConfig(),
|
|
|
|
|
'/v1': createProxyConfig(),
|
|
|
|
|
'/health': createProxyConfig(),
|
2026-04-11 21:33:04 +08:00
|
|
|
'/upload': createProxyConfig(),
|
|
|
|
|
'/webhook': createProxyConfig(),
|
2026-04-24 20:41:14 +08:00
|
|
|
'/socket.io': {
|
|
|
|
|
target: BACKEND,
|
|
|
|
|
ws: true,
|
|
|
|
|
},
|
2026-04-11 15:59:14 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|