import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import svgr from "vite-plugin-svgr";
import tailwindcss from "@tailwindcss/vite";

export default defineConfig({
  plugins: [react(), tailwindcss(), svgr()],
  server: {
    host: true,
    port: 3000,
    strictPort: true,
    proxy: {
      "/api/habackend": {
        target: "https://habackend.rasadyar.com",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api\/habackend/, ""),
        secure: true,
      },
      "/api/mabackend": {
        target: "https://mabackend.rasadyar.com",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api\/mabackend/, ""),
        secure: true,
      },
      "/api/bubackend": {
        target: "https://bubackend.rasadyar.com",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api\/bubackend/, ""),
        secure: true,
      },
    },
  },
  preview: {
    allowedHosts: [
      "ban.rasadyar.com",
      "ban.rasadyar.net",
      "www.ban.rasadyar.com",
      "www.ban.rasadyar.net",
    ],
  },
  build: {
    outDir: "build",
  },
  resolve: {
    alias: {
      "@": "/src",
    },
  },
});
