1import * as Namespace from "../../Namespace.ts";
2import { makeFrameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts";
3
4/** The framework-integration package that drives the Nuxt build. */
5export const NUXT_FRAMEWORK_SPECIFIER = "@alchemy.run/frontend-frameworks/nuxt";
6
7/** The Node container deploy target for the Nuxt build. */
8export const NUXT_NODE_TARGET_SPECIFIER =
9 "@alchemy.run/frontend-frameworks/nuxt/node";
10
11export interface NuxtProps extends FrameworkSiteProps {
12 /**
13 * Nuxt config overrides merged over the project's own `nuxt.config.ts`
14 * (highest-priority layer). `nitro.preset` is owned by the Node deploy
15 * target (`"node"`) and may not be set here.
16 */
17 nuxt?: Record<string, unknown>;
18}
19
20/**
21 * Deploy a Nuxt application to Railway: the nitro Node server plus
22 * prerendered assets on one `Railway.Service`. The Node deploy target
23 * enforces nitro's `node` preset; do not set `nitro.preset`.
24 *
25 * During `alchemy dev` the site is Nuxt's own dev server and no cloud
26 * resources are created. `Alchemy.remote()` opts back into the live
27 * Service path.
28 *
29 * ### Creating Nuxt Sites
30 * **Example:** Basic Nuxt App
31 * ```typescript
32 * const site = yield* Railway.Website.Nuxt("Web", {
33 * rootDir: "./app",
34 * });
35 * ```
36 *
37 * ### Server Configuration
38 * **Example:** Process Environment
39 * ```typescript
40 * const site = yield* Railway.Website.Nuxt("Web", {
41 * rootDir: "./app",
42 * env: {
43 * NUXT_PUBLIC_API_BASE: "https://api.example.com",
44 * },
45 * });
46 * ```
47 *
48 * @resource
49 * @product Website
50 */
51export const Nuxt = (id: string, props: NuxtProps = {}) =>
52 makeFrameworkSite(id, props, {
53 name: "Nuxt",
54 framework: NUXT_FRAMEWORK_SPECIFIER,
55 target: NUXT_NODE_TARGET_SPECIFIER,
56 options: props.nuxt ? { nuxt: props.nuxt } : undefined,
57 }).pipe(Namespace.push(id));