28 lines
804 B
TypeScript
28 lines
804 B
TypeScript
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import { defineConfig, loadEnv } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
// FIX: Derive __dirname in ESM environment to resolve "Cannot find name '__dirname'" error
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, '.', '');
|
|
return {
|
|
server: {
|
|
port: 3000,
|
|
host: '0.0.0.0',
|
|
},
|
|
plugins: [react()],
|
|
define: {
|
|
'process.env.API_KEY': JSON.stringify(env.GEMINI_API_KEY),
|
|
'process.env.GEMINI_API_KEY': JSON.stringify(env.GEMINI_API_KEY)
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, '.'),
|
|
}
|
|
}
|
|
};
|
|
}); |