W3cubDocs

/Angular

generate service-worker

ng generate service-worker [options]

Adds a service worker to your project. Service workers enable your application to work offline or on low-quality networks by caching assets and intercepting network requests. This schematic configures your project to use a service worker.

Options

project

The name of the project to add the service worker to. If not specified, the CLI will determine the project from the current directory.

Value Type

string

target

The build target to apply the service worker to. This is typically build, indicating that the service worker should be generated during the standard build process.

Value Type

string

Default

build

Super-powered by Google ©2010–2025.
Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0.
https://angular.dev/cli/generate/service-worker