Skip to main content

Astro integration

import * as mod from "jsr:@nzip/lofi/astro";

Astro and Vite integration used by generated lofi applications.

prepareLofiAstroConfig materializes version-matched runtime aliases and Jazz configuration into the ignored .lofi/ directory.

The generated configuration reads these environment variables at Astro config-load time:

  • LOFI_BASE_PATH — deployment base path for the built site (default /).
  • LOFI_CSP — set to off to disable the Content-Security-Policy meta tags Astro emits per page (on by default).
  • LOFI_CSP_SCRIPT_SRC — space-separated sources appended to the script-src directive.
  • LOFI_CSP_STYLE_SRC — space-separated sources appended to the style-src directive.
  • LOFI_CSP_CONNECT_SRC — sources for a connect-src directive; absent by default because the sync location is user data enrolled at runtime.
  • LOFI_CSP_DIRECTIVES — semicolon-separated additional CSP directives.
  • JAZZ_APP_ID — cloud-mode Jazz application id; requires JAZZ_SERVER_URL.
  • JAZZ_SERVER_URL — cloud-mode Jazz sync server URL; requires JAZZ_APP_ID.
  • LOFI_SKIP_JAZZ_MANAGED — set to 1 to skip starting the managed local Jazz server during development.

prepareLofiAstroConfig

function

async function prepareLofiAstroConfig(options: LofiAstroOptions): Promise<string>

Materializes the package-owned Astro/Jazz integration into an ignored tooling directory so Astro's Node-compatible config loader can consume it.

Vendors the runtime, access, preact, recipe, and schema modules into .lofi/package/ and writes .lofi/astro.config.ts, rewriting the config only when its content changes.

ParameterDescription
optionsThe project root and schema directory; both optional.

Returns: The absolute path of the generated .lofi/astro.config.ts.

LofiAstroOptions

type

type LofiAstroOptions = {
root?: string;
schemaDir?: "src";
};

Options for materializing the package-owned Astro configuration.