| 1 | import * as Namespace from "../../Namespace.ts"; |
| 2 | import { makeFrameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts"; |
| 3 | |
| 4 | /** Configuration for a Prisma SvelteKit website. */ |
| 5 | export interface SvelteKitProps extends FrameworkSiteProps { |
| 6 | /** Serializable SvelteKit v3 plugin configuration. The Node target owns adapter. */ |
| 7 | kit?: Record<string, unknown>; |
| 8 | } |
| 9 | |
| 10 | /** |
| 11 | * SvelteKit SSR and prerendered assets on Prisma Compute. The Node target injects the adapter. For Kit v3, pass configuration through kit rather than a svelte.config.js file. |
| 12 | * |
| 13 | * Native framework development and HMR run without Prisma cloud resources. |
| 14 | * Apply `Alchemy.remote()` to use the live Compute deployment during dev. |
| 15 | * Packaging requires the optional `@vercel/nft` peer dependency. |
| 16 | * |
| 17 | * ### Creating a Website |
| 18 | * **Example:** SvelteKit application |
| 19 | * ```typescript |
| 20 | * const site = yield* Prisma.Website.SvelteKit("Web", { |
| 21 | * rootDir: "./app", |
| 22 | * }); |
| 23 | * ``` |
| 24 | * |
| 25 | * ### Deployment Configuration |
| 26 | * **Example:** Existing project and custom hostname |
| 27 | * ```typescript |
| 28 | * const site = yield* Prisma.Website.SvelteKit("Web", { |
| 29 | * project, |
| 30 | * domain: "www.example.com", |
| 31 | * env: { API_BASE: "https://api.example.com" }, |
| 32 | * compute: { destroyOldDeployment: true }, |
| 33 | * }); |
| 34 | * ``` |
| 35 | * |
| 36 | * @resource |
| 37 | * @product Website |
| 38 | */ |
| 39 | export const SvelteKit = (id: string, props: SvelteKitProps = {}) => |
| 40 | makeFrameworkSite(id, props, { |
| 41 | framework: "@alchemy.run/frontend-frameworks/sveltekit", |
| 42 | target: "@alchemy.run/frontend-frameworks/sveltekit/node", |
| 43 | options: { kit: props.kit }, |
| 44 | }).pipe(Namespace.push(id)); |