| 1 | import { frameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts"; |
| 2 | |
| 3 | /** The framework-integration package that drives the SvelteKit build. */ |
| 4 | export const SVELTEKIT_FRAMEWORK_SPECIFIER = |
| 5 | "@alchemy.run/frontend-frameworks/sveltekit"; |
| 6 | |
| 7 | /** The Node container deploy target for the SvelteKit build. */ |
| 8 | export const SVELTEKIT_NODE_TARGET_SPECIFIER = |
| 9 | "@alchemy.run/frontend-frameworks/sveltekit/node"; |
| 10 | |
| 11 | export interface SvelteKitProps extends FrameworkSiteProps { |
| 12 | /** |
| 13 | * SvelteKit configuration passed to the `sveltekit(config)` Vite plugin. |
| 14 | * The `adapter` field is injected by the Node deploy target and may not |
| 15 | * be set here. Must be JSON-serializable. |
| 16 | */ |
| 17 | kit?: Record<string, unknown>; |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * Deploy a SvelteKit application to Cloud Run: kit's SSR server in a Cloud Run container, |
| 22 | * static assets baked into the image, served assets-first then the |
| 23 | * framework handler. |
| 24 | * |
| 25 | * |
| 26 | * ### Creating SvelteKit Sites |
| 27 | * **Example:** Basic SvelteKit App |
| 28 | * ```typescript |
| 29 | * const site = yield* GCP.Website.SvelteKit("Web", { |
| 30 | * rootDir: "./app", |
| 31 | * }); |
| 32 | * ``` |
| 33 | * |
| 34 | * **Example:** Warm Instance with More Memory |
| 35 | * ```typescript |
| 36 | * const site = yield* GCP.Website.SvelteKit("Web", { |
| 37 | * rootDir: "./app", |
| 38 | * scaling: { minInstanceCount: 1 }, |
| 39 | * resources: { limits: { cpu: "1", memory: "1Gi" } }, |
| 40 | * }); |
| 41 | * ``` |
| 42 | * |
| 43 | * @resource |
| 44 | * @product Website |
| 45 | */ |
| 46 | export const SvelteKit = (id: string, props: SvelteKitProps = {}) => |
| 47 | frameworkSite(id, props, { |
| 48 | name: "SvelteKit", |
| 49 | framework: SVELTEKIT_FRAMEWORK_SPECIFIER, |
| 50 | target: SVELTEKIT_NODE_TARGET_SPECIFIER, |
| 51 | options: props.kit ? { kit: props.kit } : undefined, |
| 52 | }); |