import { readFileSync } from 'node:fs' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf-8')) as { version: string } export default defineConfig({ base: process.env.VITE_BASE_PATH || '/', plugins: [vue()], define: { __APP_VERSION__: JSON.stringify(process.env.VITE_APP_VERSION || pkg.version), }, server: { port: 5173, allowedHosts: true, proxy: { '/api': { target: 'http://localhost:6893', // 内置 SSH 终端走 WebSocket:开发代理必须开 ws,否则升级请求会一直挂起 ws: true, timeout: 300_000, proxyTimeout: 300_000, configure(proxy) { proxy.on('proxyRes', (proxyRes, req) => { if (req.url?.includes('/stream')) { proxyRes.headers['cache-control'] = 'no-cache' proxyRes.headers['x-accel-buffering'] = 'no' } }) }, }, }, }, build: { outDir: 'dist', emptyOutDir: true, }, })