| 1 | import { Vite, type ViteProps } from "./Vite.ts"; |
| 2 | |
| 3 | export interface FoldkitProps extends ViteProps {} |
| 4 | |
| 5 | /** |
| 6 | * Deploy a [Foldkit](https://foldkit.dev) app to Railway: a Vite SPA with |
| 7 | * unmatched paths falling back to `index.html` so deep links boot the |
| 8 | * Foldkit router. Same Node static-file Service as {@link Vite}. |
| 9 | * |
| 10 | * Foldkit apps are client-only Vite projects — the Foldkit Vite plugin in |
| 11 | * the app's `vite.config.ts` composes with the project's own Vite build. |
| 12 | * |
| 13 | * During `alchemy dev` the site is Vite's own dev server and no cloud |
| 14 | * resources are created. `Alchemy.remote()` opts back into the live |
| 15 | * Service path. |
| 16 | * |
| 17 | * ### Deploying a Foldkit App |
| 18 | * **Example:** Foldkit app |
| 19 | * ```typescript |
| 20 | * const site = yield* Railway.Website.Foldkit("Website"); |
| 21 | * ``` |
| 22 | * |
| 23 | * **Example:** Foldkit project in a subdirectory |
| 24 | * ```typescript |
| 25 | * const site = yield* Railway.Website.Foldkit("Website", { |
| 26 | * rootDir: "applications/web", |
| 27 | * }); |
| 28 | * ``` |
| 29 | * |
| 30 | * ### Single-Page Application Routing |
| 31 | * **Example:** Serving a real 404 page |
| 32 | * ```typescript |
| 33 | * const site = yield* Railway.Website.Foldkit("Website", { |
| 34 | * assets: { notFoundHandling: "404-page" }, |
| 35 | * }); |
| 36 | * ``` |
| 37 | * |
| 38 | * @resource |
| 39 | * @product Website |
| 40 | */ |
| 41 | export const Foldkit = (id: string, props: FoldkitProps = {}) => |
| 42 | Vite(id, { |
| 43 | ...props, |
| 44 | assets: { |
| 45 | notFoundHandling: "single-page-application", |
| 46 | ...props.assets, |
| 47 | }, |
| 48 | }); |