Refactor Vite configuration and add environment type definitions
- Removed local Vite config file - Updated dev scripts to use default config - Added env.d.ts for type definitions - Enhanced Vite config with dynamic proxy - Simplified build and dev script commands
This commit is contained in:
@@ -4,11 +4,11 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bunx --bun vite --config vite.config.local.js",
|
"dev": "bunx --bun vite",
|
||||||
"build": "bunx --bun vite build",
|
"build": "bunx --bun vite build",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"preview": "bunx --bun vite preview",
|
"preview": "bunx --bun vite preview",
|
||||||
"dev-no-bun": "vite --config vite.config.local.js",
|
"dev-no-bun": "vite",
|
||||||
"build-no-bun": "vite build --emptyOutDir",
|
"build-no-bun": "vite build --emptyOutDir",
|
||||||
"preview-no-bun": "vite preview"
|
"preview-no-bun": "vite preview"
|
||||||
},
|
},
|
||||||
|
7
lightrag_webui/src/env.d.ts
vendored
Normal file
7
lightrag_webui/src/env.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
interface ImportMetaEnv {
|
||||||
|
readonly VITE_API_PROXY: string
|
||||||
|
readonly VITE_API_ENDPOINTS: string
|
||||||
|
readonly VITE_BACKEND_URL: string
|
||||||
|
}
|
@@ -1,38 +0,0 @@
|
|||||||
import { defineConfig } from 'vite'
|
|
||||||
import baseConfig from './vite.config'
|
|
||||||
import { mergeConfig } from 'vite'
|
|
||||||
|
|
||||||
export default mergeConfig(
|
|
||||||
baseConfig,
|
|
||||||
defineConfig({
|
|
||||||
server: {
|
|
||||||
proxy: {
|
|
||||||
'/api': {
|
|
||||||
target: 'http://localhost:9621',
|
|
||||||
changeOrigin: true,
|
|
||||||
rewrite: (path) => path.replace(/^\/api/, '')
|
|
||||||
},
|
|
||||||
'/documents': {
|
|
||||||
target: 'http://localhost:9621',
|
|
||||||
changeOrigin: true
|
|
||||||
},
|
|
||||||
'/graphs': {
|
|
||||||
target: 'http://localhost:9621',
|
|
||||||
changeOrigin: true
|
|
||||||
},
|
|
||||||
'/graph': {
|
|
||||||
target: 'http://localhost:9621',
|
|
||||||
changeOrigin: true
|
|
||||||
},
|
|
||||||
'/health': {
|
|
||||||
target: 'http://localhost:9621',
|
|
||||||
changeOrigin: true
|
|
||||||
},
|
|
||||||
'/query': {
|
|
||||||
target: 'http://localhost:9621',
|
|
||||||
changeOrigin: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
@@ -16,5 +16,19 @@ export default defineConfig({
|
|||||||
build: {
|
build: {
|
||||||
outDir: path.resolve(__dirname, '../lightrag/api/webui'),
|
outDir: path.resolve(__dirname, '../lightrag/api/webui'),
|
||||||
emptyOutDir: true
|
emptyOutDir: true
|
||||||
|
},
|
||||||
|
server: {
|
||||||
|
proxy: import.meta.env.VITE_API_PROXY === 'true' && import.meta.env.VITE_API_ENDPOINTS ?
|
||||||
|
Object.fromEntries(
|
||||||
|
import.meta.env.VITE_API_ENDPOINTS.split(',').map(endpoint => [
|
||||||
|
endpoint,
|
||||||
|
{
|
||||||
|
target: import.meta.env.VITE_BACKEND_URL || 'http://localhost:9621',
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: endpoint === '/api' ?
|
||||||
|
(path) => path.replace(/^\/api/, '') : undefined
|
||||||
|
}
|
||||||
|
])
|
||||||
|
) : {}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user