vite.config.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import path from 'path';
  2. import { defineConfig, loadEnv } from 'vite';
  3. import react from '@vitejs/plugin-react';
  4. import tailwindcss from '@tailwindcss/vite';
  5. export default defineConfig(({ mode }) => {
  6. const env = loadEnv(mode, '.', '');
  7. return {
  8. server: {
  9. port: Number(env.VITE_PORT) || 13001,
  10. host: env.VITE_HOST || '0.0.0.0',
  11. proxy: {
  12. '/api': {
  13. target: env.VITE_BACKEND_URL || 'http://localhost:3001',
  14. changeOrigin: true,
  15. },
  16. '/uploads': {
  17. target: env.VITE_BACKEND_URL || 'http://localhost:3001',
  18. changeOrigin: true,
  19. },
  20. },
  21. },
  22. plugins: [tailwindcss() as any, react()],
  23. define: {
  24. 'process.env.API_KEY': JSON.stringify(env.GEMINI_API_KEY),
  25. 'process.env.GEMINI_API_KEY': JSON.stringify(env.GEMINI_API_KEY)
  26. },
  27. optimizeDeps: {
  28. exclude: ['tailwindcss']
  29. },
  30. resolve: {
  31. alias: {
  32. '@': path.resolve(__dirname, '.'),
  33. }
  34. },
  35. publicDir: 'public'
  36. };
  37. });
  38. // touch