2025-02-09 23:15:26 +08:00
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
import path from 'path'
|
2025-03-14 17:00:36 +08:00
|
|
|
import { webuiPrefix } from '@/lib/constants'
|
2025-02-09 23:15:26 +08:00
|
|
|
import react from '@vitejs/plugin-react-swc'
|
|
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
|
|
|
|
|
|
// https://vite.dev/config/
|
|
|
|
export default defineConfig({
|
|
|
|
plugins: [react(), tailwindcss()],
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@': path.resolve(__dirname, './src')
|
|
|
|
}
|
|
|
|
},
|
2025-03-14 17:00:36 +08:00
|
|
|
// base: import.meta.env.VITE_BASE_URL || '/webui/',
|
|
|
|
base: webuiPrefix,
|
2025-02-13 17:53:12 +08:00
|
|
|
build: {
|
2025-03-05 12:54:15 +08:00
|
|
|
outDir: path.resolve(__dirname, '../lightrag/api/webui'),
|
|
|
|
emptyOutDir: true
|
2025-03-05 18:25:51 +08:00
|
|
|
},
|
|
|
|
server: {
|
2025-03-07 08:17:25 +08:00
|
|
|
proxy: import.meta.env.VITE_API_PROXY === 'true' && import.meta.env.VITE_API_ENDPOINTS ?
|
2025-03-05 18:25:51 +08:00
|
|
|
Object.fromEntries(
|
|
|
|
import.meta.env.VITE_API_ENDPOINTS.split(',').map(endpoint => [
|
|
|
|
endpoint,
|
|
|
|
{
|
|
|
|
target: import.meta.env.VITE_BACKEND_URL || 'http://localhost:9621',
|
|
|
|
changeOrigin: true,
|
2025-03-07 08:17:25 +08:00
|
|
|
rewrite: endpoint === '/api' ?
|
2025-03-13 12:38:33 +08:00
|
|
|
(path) => path.replace(/^\/api/, '') :
|
|
|
|
endpoint === '/docs' || endpoint === '/openapi.json' ?
|
|
|
|
(path) => path : undefined
|
2025-03-05 18:25:51 +08:00
|
|
|
}
|
|
|
|
])
|
|
|
|
) : {}
|
2025-02-13 17:53:12 +08:00
|
|
|
}
|
2025-02-10 00:33:39 +08:00
|
|
|
})
|