// src/svelte.ts
function setupVite(vite) {
  vite.ssr = vite.ssr || {};
  vite.ssr.external = ["@serverless/cloud"].concat(vite.ssr.external);
  vite.build = vite.build || {};
  vite.build.rollupOptions = vite.build.rollupOptions || {};
  vite.build.rollupOptions.external = ["@serverless/cloud"].concat(vite.build.rollupOptions.external || []);
}
module.exports = function withCloud(options = {}) {
  options.kit = options.kit || {};
  options.kit.adapter = {
    name: "@serverless/cloud",
    async adapt(builder) {
      const svelte = "svelte";
      builder.rimraf(svelte);
      builder.writeServer(svelte);
      const static_ = "static";
      builder.rimraf(static_);
      builder.writeStatic(static_);
      builder.writeClient(static_);
      builder.writePrerendered(static_);
    }
  };
  options.kit.vite = options.kit.vite || {};
  setupVite(options.kit.vite);
  options.kit.files = options.kit.files || {};
  options.kit.files.assets = options.kit.files.assets || "src/assets";
  return options;
};
