[]previous and next page

computeAssets

Computes what the server puts in the page for each route: the entry, the stylesheets every page needs, and per route the chunks and stylesheets of its lazily loaded UI that the entry does not already bring.

Computes what the server puts in the page for each route: the entry, the stylesheets every page needs, and per route the chunks and stylesheets of its lazily loaded UI that the entry does not already bring. Lists are deduplicated and cut to maxPreloads.

Import#

ts
import { computeAssets } from "@shadow-js/dusk/vite";

Signature#

ts
function computeAssets(input: {
  readonly manifest: ViteManifest;
  readonly scan: ScanResult;
  readonly root: string;
  readonly base: string;
  readonly maxPreloads: number;
  /** The CDN origin of the built assets (`assetOrigin`); the file names become `<origin><base><file>`. */
  readonly origin?: string;
}): BuiltAssets

Parameters#

Name Description
input The Vite manifest, the scanned routes and the project root.

Returns#

The asset section and the route facts.

Throws#

  • Error when the manifest has no entry chunk.

Examples#

ts
const { assets } = computeAssets({ manifest, scan, root, base: "/", maxPreloads: 24 });