vite.config.ts 612 B

12345678910111213141516171819202122
  1. import react from "@vitejs/plugin-react";
  2. import { defineConfig, loadEnv } from "vite";
  3. // https://vitejs.dev/config/
  4. export default defineConfig(({ mode }) => {
  5. // Load env file based on `mode` in the current directory.
  6. // Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
  7. const env = loadEnv(mode, process.cwd(), '');
  8. return {
  9. plugins: [react()],
  10. // Make Vite aware of the env variables
  11. define: {
  12. 'process.env': env
  13. },
  14. // Enable CORS for development
  15. server: {
  16. cors: true,
  17. port: env.PORT ? Number(env.PORT) : 3000,
  18. }
  19. }
  20. });