Fix swagger docs page problem in dev mode
- Add /static to VITE_API_ENDPOINTS
- Update proxy rewrite rules
- Include static file serving
- Sync sample env file
(cherry picked from commit ee7c683fa7)
This commit is contained in:
parent
8c7b0017df
commit
2d85e9f2f8
3 changed files with 17 additions and 44 deletions
4
lightrag_webui/.env.development
Normal file
4
lightrag_webui/.env.development
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
# Development environment configuration
|
||||||
|
VITE_BACKEND_URL=http://localhost:9621
|
||||||
|
VITE_API_PROXY=true
|
||||||
|
VITE_API_ENDPOINTS=/api,/documents,/graphs,/graph,/health,/query,/docs,/redoc,/openapi.json,/login,/auth-status,/static
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
# Development environment configuration
|
# Development environment configuration
|
||||||
VITE_BACKEND_URL=/api
|
VITE_BACKEND_URL=http://localhost:9621
|
||||||
|
VITE_API_PROXY=true
|
||||||
|
VITE_API_ENDPOINTS=/api,/documents,/graphs,/graph,/health,/query,/docs,/redoc,/openapi.json,/login,/auth-status,/static
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,9 @@
|
||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import { webuiPrefix } from '@/lib/constants'
|
||||||
import react from '@vitejs/plugin-react-swc'
|
import react from '@vitejs/plugin-react-swc'
|
||||||
import tailwindcss from '@tailwindcss/vite'
|
import tailwindcss from '@tailwindcss/vite'
|
||||||
|
|
||||||
// Get the base URL from environment or default to /
|
|
||||||
const getBaseUrl = (): string => {
|
|
||||||
return process.env.VITE_BASE_URL || '/'
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react(), tailwindcss()],
|
plugins: [react(), tailwindcss()],
|
||||||
|
|
@ -16,44 +12,15 @@ export default defineConfig({
|
||||||
'@': path.resolve(__dirname, './src')
|
'@': path.resolve(__dirname, './src')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
base: getBaseUrl(),
|
// base: import.meta.env.VITE_BASE_URL || '/webui/',
|
||||||
|
base: webuiPrefix,
|
||||||
build: {
|
build: {
|
||||||
outDir: 'dist',
|
outDir: path.resolve(__dirname, '../lightrag/api/webui'),
|
||||||
emptyOutDir: true,
|
emptyOutDir: true,
|
||||||
chunkSizeWarningLimit: 1000,
|
chunkSizeWarningLimit: 3800,
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
// Handle circular dependencies and module initialization
|
// Let Vite handle chunking automatically to avoid circular dependency issues
|
||||||
external: [],
|
|
||||||
output: {
|
output: {
|
||||||
// Manual chunking strategy
|
|
||||||
manualChunks: {
|
|
||||||
// Group React-related libraries into one chunk
|
|
||||||
'react-vendor': ['react', 'react-dom', 'react-router-dom'],
|
|
||||||
// Group graph visualization libraries into one chunk
|
|
||||||
'graph-vendor': ['sigma', 'graphology', '@react-sigma/core'],
|
|
||||||
// Group UI component libraries into one chunk
|
|
||||||
'ui-vendor': ['@radix-ui/react-dialog', '@radix-ui/react-popover', '@radix-ui/react-select', '@radix-ui/react-tabs'],
|
|
||||||
// Group utility libraries into one chunk
|
|
||||||
'utils-vendor': ['axios', 'i18next', 'zustand', 'clsx', 'tailwind-merge'],
|
|
||||||
// Separate feature modules
|
|
||||||
'feature-graph': ['./src/features/GraphViewer'],
|
|
||||||
'feature-documents': ['./src/features/DocumentManager'],
|
|
||||||
'feature-retrieval': ['./src/features/RetrievalTesting'],
|
|
||||||
|
|
||||||
// Mermaid-related modules
|
|
||||||
'mermaid-vendor': ['mermaid'],
|
|
||||||
|
|
||||||
// Markdown-related modules
|
|
||||||
'markdown-vendor': [
|
|
||||||
'react-markdown',
|
|
||||||
'rehype-react',
|
|
||||||
'rehype-raw',
|
|
||||||
'remark-gfm',
|
|
||||||
'remark-math',
|
|
||||||
'react-syntax-highlighter',
|
|
||||||
'unist-util-visit'
|
|
||||||
]
|
|
||||||
},
|
|
||||||
// Ensure consistent chunk naming format
|
// Ensure consistent chunk naming format
|
||||||
chunkFileNames: 'assets/[name]-[hash].js',
|
chunkFileNames: 'assets/[name]-[hash].js',
|
||||||
// Entry file naming format
|
// Entry file naming format
|
||||||
|
|
@ -64,16 +31,16 @@ export default defineConfig({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
proxy: process.env.VITE_API_PROXY === 'true' && process.env.VITE_API_ENDPOINTS ?
|
proxy: import.meta.env.VITE_API_PROXY === 'true' && import.meta.env.VITE_API_ENDPOINTS ?
|
||||||
Object.fromEntries(
|
Object.fromEntries(
|
||||||
process.env.VITE_API_ENDPOINTS.split(',').map(endpoint => [
|
import.meta.env.VITE_API_ENDPOINTS.split(',').map(endpoint => [
|
||||||
endpoint,
|
endpoint,
|
||||||
{
|
{
|
||||||
target: process.env.VITE_BACKEND_URL || 'http://localhost:9621',
|
target: import.meta.env.VITE_BACKEND_URL || 'http://localhost:9621',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: endpoint === '/api' ?
|
rewrite: endpoint === '/api' ?
|
||||||
(path) => path.replace(/^\/api/, '') :
|
(path) => path.replace(/^\/api/, '') :
|
||||||
endpoint === '/docs' || endpoint === '/openapi.json' ?
|
endpoint === '/docs' || endpoint === '/redoc' || endpoint === '/openapi.json' || endpoint === '/static' ?
|
||||||
(path) => path : undefined
|
(path) => path : undefined
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue