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

/** @type {import('@sveltejs/kit').Config} */
const config = {
  preprocess: vitePreprocess(),
  kit: {
    adapter: adapter({
      pages: 'build',
      assets: 'build',
      fallback: undefined,
      precompress: false,
      strict: true
    }),
    prerender: {
      handleHttpError: ({ path, message }) => {
        // Ignore external links (they'll be served by Caddy separately)
        // These are deployed as separate apps
        if (
          path.startsWith('/guides/statistical-tests') ||
          path.startsWith('/tools/flowchart') ||
          path.startsWith('/statistical-tests') ||
          path.startsWith('/flowchart') ||
          path.startsWith('/data-visualization') ||
          path.startsWith('/interactive-tools')
        ) {
          return;
        }
        throw new Error(message);
      }
    }
  }
};

export default config;
