69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
import { defineConfig, loadEnv } from 'vite'
|
|
import uni from '@dcloudio/vite-plugin-uni'
|
|
|
|
const normalizeEnvUrl = (value: string | undefined, fallback: string) => {
|
|
const normalized = value?.trim()
|
|
return normalized || fallback
|
|
}
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), '')
|
|
const appApiProxyTarget = normalizeEnvUrl(env.DEV_PROXY_APP_API_TARGET, 'http://localhost:3001')
|
|
const h5SdkProxyTarget = normalizeEnvUrl(env.DEV_PROXY_H5_SDK_TARGET, appApiProxyTarget)
|
|
const sdkProxyTarget = normalizeEnvUrl(env.DEV_PROXY_SDK_TARGET, appApiProxyTarget)
|
|
const museumAssetsProxyTarget = normalizeEnvUrl(env.DEV_PROXY_MUSEUM_ASSETS_TARGET, 'http://localhost:9000')
|
|
const minioProxyTarget = normalizeEnvUrl(env.DEV_PROXY_MINIO_TARGET, appApiProxyTarget)
|
|
const audioProxyTarget = normalizeEnvUrl(env.DEV_PROXY_AUDIO_TARGET, 'http://localhost:19000')
|
|
|
|
return {
|
|
base: normalizeEnvUrl(env.VITE_APP_PUBLIC_BASE, '/'),
|
|
plugins: [uni()],
|
|
server: {
|
|
host: '0.0.0.0',
|
|
proxy: {
|
|
'/app-api': {
|
|
target: appApiProxyTarget,
|
|
changeOrigin: true
|
|
},
|
|
'/h5-sdk': {
|
|
target: h5SdkProxyTarget,
|
|
changeOrigin: true
|
|
},
|
|
'/sdk': {
|
|
target: sdkProxyTarget,
|
|
changeOrigin: true
|
|
},
|
|
'/museum-assets': {
|
|
target: museumAssetsProxyTarget,
|
|
changeOrigin: true
|
|
},
|
|
'/minio': {
|
|
target: minioProxyTarget,
|
|
changeOrigin: true
|
|
},
|
|
'/nhm/audio': {
|
|
target: audioProxyTarget,
|
|
changeOrigin: true
|
|
}
|
|
}
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': '/src'
|
|
}
|
|
},
|
|
optimizeDeps: {
|
|
include: ['three']
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
three: ['three']
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|