1import * as Namespace from "../../Namespace.ts";
2import { makeFrameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts";
3
4/** Configuration for a Neon Vite website. */
5export type ViteProps = FrameworkSiteProps & {
6 /** Serializable overrides merged over vite.config.*. */
7 vite?: {
8 /** Build output directory. @default "dist" */
9 outDir?: string;
10 /** Public base path. @default "/" */
11 base?: string;
12 };
13};
14
15/**
16 * Static Vite assets served on Neon Functions. The project’s Vite plugins and configuration drive the build; native Vite HMR runs during development.
17 *
18 * Native framework development and HMR run without Neon cloud resources.
19 * Apply `Alchemy.remote()` to use the live Function deployment during dev.
20 * Packaging requires the optional `@vercel/nft` peer dependency.
21 *
22 * ### Creating a Website
23 * **Example:** Vite application
24 * ```typescript
25 * const site = yield* Neon.Website.Vite("Web", {
26 * rootDir: "./app",
27 * });
28 * ```
29 *
30 * ### Deployment Configuration
31 * **Example:** Existing project and custom hostname
32 * ```typescript
33 * const site = yield* Neon.Website.Vite("Web", {
34 * project,
35 * domain: "www.example.com",
36 * env: { API_BASE: "https://api.example.com" },
37 * function: { name: "Website" },
38 * });
39 * ```
40 *
41 * @resource
42 * @product Website
43 */
44export const Vite = (id: string, props: ViteProps = {}) =>
45 makeFrameworkSite(id, props, {
46 framework: "@alchemy.run/frontend-frameworks/vite",
47 target: "@alchemy.run/frontend-frameworks/vite/neon",
48 options: { vite: props.vite },
49 notFoundHandling: "spa",
50 }).pipe(Namespace.push(id));