Files
audi-rednote/audi-content-portal/vite.config.ts

30 lines
843 B
TypeScript
Raw Normal View History

2026-04-13 20:28:09 +08:00
import tailwindcss from '@tailwindcss/vite';
import react from '@vitejs/plugin-react';
import { defineConfig, loadEnv } from 'vite';
import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';
// 手动定义 __dirname 以确保在 Windows 下的兼容性
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, '.', '');
return {
2026-04-15 17:08:17 +08:00
base: './',
2026-04-13 20:28:09 +08:00
plugins: [react(), tailwindcss()],
define: {
'process.env.GEMINI_API_KEY': JSON.stringify(env.GEMINI_API_KEY),
},
resolve: {
alias: {
// 使用 resolve 确保路径在 Windows/Linux 下都能正确解析
'@': resolve(__dirname, './src'),
},
},
server: {
port: 3000,
host: '0.0.0.0',
},
};
});