修改打包后到base_url

This commit is contained in:
xie7654
2025-07-05 10:46:25 +08:00
parent 98060beea9
commit f2b6aa0707
4 changed files with 26 additions and 7 deletions

View File

@@ -11,10 +11,15 @@ export default defineConfig(async ({ mode }) => {
const env = loadEnv(mode, process.cwd());
// 这样获取
const backendUrl = env.VITE_BACKEND_URL;
console.log(backendUrl);
// 判断是否为构建模式
const isBuild = mode === 'production';
const isOssEnabled = env.VITE_OSS_ENABLED === 'true';
return {
application: {},
vite: {
base: isBuild && isOssEnabled ? env.VITE_BASE_URL_PROD : '',
server: {
host: '0.0.0.0', // 保证 docker 内外都能访问
port: 5678,