2025-04-29 18:36:29 +08:00
|
|
|
import { defineConfig } from 'vite';
|
2025-05-17 23:12:41 +08:00
|
|
|
import dotenv from 'dotenv';
|
|
|
|
import path from 'path';
|
|
|
|
import fs from 'fs';
|
|
|
|
|
|
|
|
// 加载环境变量
|
|
|
|
dotenv.config();
|
|
|
|
|
|
|
|
// 然后根据 NODE_ENV 再次加载 .env.production 或 .env.staging
|
|
|
|
const mode = process.env.NODE_ENV || 'development';
|
|
|
|
const envPath = path.resolve(__dirname, `.env.${mode}`);
|
|
|
|
if (fs.existsSync(envPath)) {
|
|
|
|
dotenv.config({ path: envPath });
|
|
|
|
}
|
2025-04-29 18:36:29 +08:00
|
|
|
|
|
|
|
// https://vitejs.dev/config
|
|
|
|
export default defineConfig({
|
|
|
|
build: {
|
|
|
|
rollupOptions: {
|
|
|
|
input: {
|
|
|
|
login: 'login.html',
|
|
|
|
index: 'index.html'
|
|
|
|
}
|
|
|
|
}
|
2025-05-17 23:12:41 +08:00
|
|
|
},
|
|
|
|
// 使用 Vite 的 env 配置
|
|
|
|
envPrefix: ['EIAC_DESKTOP_API_HOST', 'NODE_ENV'],
|
|
|
|
// 定义环境变量
|
|
|
|
define: {
|
|
|
|
// 使用 process.env 访问环境变量
|
|
|
|
'process.env.EIAC_DESKTOP_API_HOST': JSON.stringify(process.env.EIAC_DESKTOP_API_HOST || 'http://1.12.73.211:8848'),
|
|
|
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
|
2025-04-29 18:36:29 +08:00
|
|
|
}
|
|
|
|
});
|