skillhub/web/vite.config.ts
philsun 34f244e7a4 feat(web): support configurable base-path deployment
Signed-off-by: philsun <xinyi.sun@daocloud.io>
2026-08-05 12:50:26 +08:00

48 lines
1 KiB
TypeScript

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import { validateBasePath } from './base-path-config'
const JS_BUILD_TARGET = 'es2020'
const LEGACY_BROWSER_TARGETS = ['chrome83', 'edge83', 'firefox78', 'safari14']
export default defineConfig({
base: validateBasePath(process.env.VITE_BASE_PATH ?? '/'),
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
build: {
target: JS_BUILD_TARGET,
cssTarget: LEGACY_BROWSER_TARGETS,
},
optimizeDeps: {
esbuildOptions: {
target: JS_BUILD_TARGET,
},
},
test: {
exclude: ['**/node_modules/**', '**/e2e/**'],
testTimeout: 30000,
hookTimeout: 30000,
},
server: {
port: 3000,
watch: {
usePolling: true,
interval: 150,
},
proxy: {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
},
'/oauth2': {
target: 'http://localhost:8080',
changeOrigin: true,
},
},
},
})