docs: add serve section to Service-worker (#59972)

Add the section which mention way to enable service-worker during local development

Fixes #59949

PR Close #59972
This commit is contained in:
Vlad Boisa 2025-02-15 00:42:49 +00:00 committed by Jessica Janiuk
parent 4298bf199b
commit 5283c2b080

View file

@ -37,7 +37,24 @@ The CLI project is now set up to use the Angular service worker.
## Service worker in action: a tour
This section demonstrates a service worker in action,
using an example application.
using an example application. To enable service worker support during local development, use the production configuration with the following command:
<docs-code language="shell">
ng serve --prod
</docs-code>
Alternatively, you can use the [`http-server package`](https://www.npmjs.com/package/http-server) from
npm, which supports service worker applications. Run it without installation using:
<docs-code language="shell">
npx http-server -p 8080 -c-1 dist/&lt;project-name&gt;/browser
</docs-code>
This will serve your application with service worker support at http://localhost:8080.
### Initial load