import cloudflareAdapter from "@sveltejs/adapter-cloudflare";
import adapter from "@sveltejs/adapter-node";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";

const useCloudflareAdapter = process.env.SVELTE_ADAPTER === "cloudflare";

const config = {
	preprocess: vitePreprocess(),
	compilerOptions: {
		runes: ({ filename }) => (filename.split(/[/\\]/).includes("node_modules") ? undefined : true)
	},
	kit: {
		adapter: useCloudflareAdapter ? cloudflareAdapter({ config: "wrangler.dev.jsonc" }) : adapter()
	}
};

export default config;
