[]previous and next page

PwaOptions

Options of pwa.

Options of pwa.

Import#

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

Signature#

ts
interface PwaOptions {
  /** The web app manifest to write. Without it no manifest file is written (serve one from a metadata route instead). */
  readonly manifest?: Manifest;
  /** The manifest's file name in the output folder. Default `manifest.webmanifest`. */
  readonly manifestFile?: string;
  /** The service worker's file name in the output folder. Default `sw.js`. */
  readonly serviceWorkerFile?: string;
  /** The prefix of every cache name; keep it unique among the apps of one origin. Default `dusk`. */
  readonly cacheNamePrefix?: string;
  /** Names the build in the cache names. Default: a hash of the precache list, so an unchanged build keeps its caches. */
  readonly buildId?: string;
  /**
   * What is kept at install. `include` and `exclude` are globs of paths in the output folder (`assets/**`). By default
   * the build's assets folder is kept; a file over `maxFileBytes` (default 2 MiB) is left out with a warning.
   */
  readonly precache?: {
    readonly include?: readonly string[];
    readonly exclude?: readonly string[];
    readonly maxFileBytes?: number;
  };
  /** Runtime caching rules, in order. Without any, only the precache and the offline fallback are active. */
  readonly runtime?: readonly PwaRuntimeRule[];
  /** Globs of the path below the mount base that the worker never touches. Default `["/_dusk/**"]`. */
  readonly exclude?: readonly string[];
  /**
   * A document that is precached and answers a navigation the network cannot. It is fetched at install, so the server
   * must answer it with a `200`. Without it the offline page answers.
   */
  readonly appShell?: string;
  /** The offline page, or `false` for none (a failed navigation is then an ordinary browser error). */
  readonly offline?: false | PwaOfflinePage;
}

Members#

Name Type Description
manifest? readonly manifest?: Manifest The web app manifest to write. Without it no manifest file is written (serve one from a metadata route instead).
manifestFile? readonly manifestFile?: string The manifest's file name in the output folder. Default manifest.webmanifest.
serviceWorkerFile? readonly serviceWorkerFile?: string The service worker's file name in the output folder. Default sw.js.
cacheNamePrefix? readonly cacheNamePrefix?: string The prefix of every cache name; keep it unique among the apps of one origin. Default dusk.
buildId? readonly buildId?: string Names the build in the cache names. Default: a hash of the precache list, so an unchanged build keeps its caches.
precache? readonly precache?: { readonly include?: readonly string[]; readonly exclude?: readonly string[]; readonly maxFileBytes?: number; } What is kept at install. include and exclude are globs of paths in the output folder (assets/**). By default the build's assets folder is kept; a file over maxFileBytes (default 2 MiB) is left out with a warning.
runtime? readonly runtime?: readonly PwaRuntimeRule[] Runtime caching rules, in order. Without any, only the precache and the offline fallback are active.
exclude? readonly exclude?: readonly string[] Globs of the path below the mount base that the worker never touches. Default ["/_dusk/**"].
appShell? readonly appShell?: string A document that is precached and answers a navigation the network cannot. It is fetched at install, so the server must answer it with a 200. Without it the offline page answers.
offline? readonly offline?: false | PwaOfflinePage The offline page, or false for none (a failed navigation is then an ordinary browser error).