import tailwindcss from "@tailwindcss/vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import react from "@vitejs/plugin-react";
import { nitro } from "nitro/vite";
import { defineConfig } from "vite";

export default defineConfig(({ mode }) => {
  const cpanelBuild = mode === "cpanel";

  return {
    resolve: { tsconfigPaths: true },
    plugins: [
      tailwindcss(),
      tanstackStart({ server: { entry: "server" } }),
      nitro({
        preset: cpanelBuild ? "node-server" : "vercel",
        ...(cpanelBuild ? { output: { dir: ".output-cpanel" } } : {}),
      }),
      react(),
    ],
  };
});
