import tailwindcss from "@tailwindcss/vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import viteReact from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";

export default defineConfig({
	plugins: [tsconfigPaths(), tailwindcss(), tanstackStart(), viteReact()],
	define: {
		global: "globalThis",
	},
	optimizeDeps: {
		include: [
			"better-auth/client",
			"better-auth/react",
			"better-auth/react-start",
		],
		exclude: ["better-auth"],
	},
	build: {
		rollupOptions: {
			external: [
				"better-auth",
				"node:async_hooks",
				"node:fs",
				"node:path",
				"node:crypto",
				"node:os",
			],
		},
	},
	ssr: {
		noExternal: [
			"better-auth/client",
			"better-auth/react",
			"better-auth/react-start",
		],
	},
});
