import path from "node:path";
import runtimeErrorOverlay from "@replit/vite-plugin-runtime-error-modal";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";

export default defineConfig({
	plugins: [
		react(),
		runtimeErrorOverlay(),
		...(process.env.NODE_ENV !== "production" &&
		process.env.REPL_ID !== undefined
			? [
					await import("@replit/vite-plugin-cartographer").then((m) =>
						m.cartographer(),
					),
				]
			: []),
	],
	resolve: {
		alias: {
			"@": path.resolve(import.meta.dirname, "client", "src"),
			"@shared": path.resolve(import.meta.dirname, "shared"),
			"@assets": path.resolve(import.meta.dirname, "attached_assets"),
			"@/shared": path.resolve(import.meta.dirname, "shared"),
			"@/hooks": path.resolve(import.meta.dirname, "client", "src", "hooks"),
			"@/api": path.resolve(import.meta.dirname, "client", "src", "lib", "api"),
		},
	},
	root: path.resolve(import.meta.dirname, "client"),
	build: {
		outDir: path.resolve(import.meta.dirname, "dist/public"),
		emptyOutDir: true,
	},
});
