import adapter from "@sveltejs/adapter-static";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";

/** @type {import('@sveltejs/kit').Config} */
export default {
	preprocess: vitePreprocess(),
	kit: {
		adapter: adapter({
			pages: "build",
			assets: "build",
			fallback: "index.html",
			strict: true,
		}),
		paths: {
			// Base path the app is served under. Empty by default so local
			// dev, vitest, and Playwright run at the root unchanged; the
			// deployed single-origin build sets BASE_PATH=/game and the
			// edge Caddy serves the SPA under that prefix.
			base: process.env.BASE_PATH ?? "",
		},
		serviceWorker: {
			// Registered manually in the root layout for production only.
			// SvelteKit's auto-registration also runs under `vite dev`, where
			// the worker would intercept and cache the dev-server e2e suite.
			register: false,
		},
	},
};
