import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import path from "path";
import { componentTagger } from "lovable-tagger";

const LOVABLE_CLOUD_URL = "https://yqdefzjapnzabowsgoyd.supabase.co";
const LOVABLE_CLOUD_PUBLISHABLE_KEY =
  "sb_publishable_RpKJhlUFdAyAz-fb7VccgA_nb3mhllk";
const LOVABLE_CLOUD_PROJECT_ID = "yqdefzjapnzabowsgoyd";

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
  server: {
    host: "::",
    port: 8080,
    hmr: {
      overlay: false,
    },
  },
  plugins: [react(), mode === "development" && componentTagger()].filter(Boolean),
  define: {
    "import.meta.env.VITE_SUPABASE_URL": JSON.stringify(LOVABLE_CLOUD_URL),
    "import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY": JSON.stringify(LOVABLE_CLOUD_PUBLISHABLE_KEY),
    "import.meta.env.VITE_SUPABASE_PROJECT_ID": JSON.stringify(LOVABLE_CLOUD_PROJECT_ID),
  },
  resolve: {
    dedupe: ["react", "react-dom"],
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
}));
