huayang/frontend/vite.config.js
2026-05-07 18:24:22 +08:00

46 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vite.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const proxyTarget = env.VITE_DEV_PROXY_TARGET || 'http://localhost:8080'
const staticOnlyMode = mode === 'development' && env.VITE_STATIC_ONLY !== 'false'
const proxy = staticOnlyMode
? undefined
: {
'/admin-api': {
target: proxyTarget,
changeOrigin: true
},
'/site': {
target: proxyTarget,
changeOrigin: true
},
'/profile': {
target: proxyTarget,
changeOrigin: true
},
'/images': {
target: proxyTarget,
changeOrigin: true
}
}
return {
base: env.VITE_BASE_URL || '/',
plugins: [vue()],
/** 归档页 HTML 打进单 chunk,体积 >500kB 属预期;仅抑制提示,非性能优化 */
build: {
chunkSizeWarningLimit: 3072
},
server: {
proxy,
host: '0.0.0.0'
},
preview: {
proxy
}
}
})