Skip to content

pwa.ts#

View Markdown

Source

8 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.

8 symbols 4 functions 3 interfaces 1 modules 7 parameters 9 members 4 returns

Reference#

fngeneratePwa(input: PwaRenderInput): PwaRenderResultBuilds manifest / service-worker bodies without writing files.

Builds manifest / service-worker bodies without writing files.

Signature

export function generatePwa(input: PwaRenderInput): PwaRenderResult

View source

Parameters

Returns

PwaRenderResult
fninjectPwaPageTags(html: string, input: { options?: ResolvedPwaOptions | null; base?: string }): stringInjects rel=manifest (and the service-worker register script when offline) into…

Injects rel=manifest (and the service-worker register script when offline) into a themed HTML document. Bare / fragment HTML is left unchanged.

Signature

export function injectPwaPageTags(html: string, input: { options?: ResolvedPwaOptions | null; base?: string }): string

View source

Parameters

Returns

string
modulepwaOpt-in web app manifest and conservative service worker. The Vite plugin writes those files during SSG without adding a…

Opt-in web app manifest and conservative service worker.

The Vite plugin writes those files during SSG without adding a NAPI surface. Enabling offline injects a tiny client script that registers sw.js.

View source

interfacePwaRenderInputInputs for rendering PWA file bodies.

Inputs for rendering PWA file bodies.

Signature

export interface PwaRenderInput

View source

Members

Properties
NameTypeDescription
baseoptional string
optionsoptional ResolvedPwaOptions | null
siteNameoptional string
siteUrloptional string
interfacePwaRenderResultRendered PWA bodies, or a skip warning.

Rendered PWA bodies, or a skip warning.

Signature

export interface PwaRenderResult

View source

Members

Properties
NameTypeDescription
manifestoptional string
serviceWorkeroptional string
warningoptional string
fnresolvePwaOptions(value: boolean | PwaOptions | undefined): ResolvedPwaOptionsResolves pwa with defaults. false / omitted stays off. true enables the manifes…

Resolves pwa with defaults.

false / omitted stays off. true enables the manifest and offline service worker. An object enables the feature and overrides only the fields the site set.

Signature

export function resolvePwaOptions(value: boolean | PwaOptions | undefined): ResolvedPwaOptions

View source

Parameters

Returns

ResolvedPwaOptions
fnwritePwaFiles(input: WritePwaFilesInput): Promise<{ files: string[]; warning?: string }>Writes enabled PWA files into outDir.

Writes enabled PWA files into outDir.

Signature

export async function writePwaFiles(input: WritePwaFilesInput): Promise<{ files: string[]; warning?: string }>

View source

Parameters

Returns

Promise<{ files: string[]; warning?: string }>
interfaceWritePwaFilesInput extends PwaRenderInputInputs for writing PWA files next to generated HTML.

Inputs for writing PWA files next to generated HTML.

Signature

export interface WritePwaFilesInput extends PwaRenderInput

View source

Members

Properties
NameTypeDescription
base string
outDir string