// src/astro.ts
module.exports = function withCloud() {
  return {
    name: "@serverless/cloud",
    hooks: {
      "astro:config:setup": ({ config }) => {
        config.vite.ssr = config.vite.ssr || {};
        config.vite.ssr.external = ["@serverless/cloud"].concat(config.vite.ssr.external || []);
        config.vite.ssr.noExternal = /@serverless\/cloud\/astro/;
      },
      "astro:config:done": ({ setAdapter }) => {
        setAdapter({
          name: "@serverless/cloud-astro",
          serverEntrypoint: "@serverless/cloud/astro-entrypoint.mjs",
          exports: ["app"]
        });
      }
    }
  };
};
