Skip to content
This repository has been archived by the owner. It is now read-only.
JSON schema for Angular service worker configuration file = great PWAs!
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests
.editorconfig
.gitignore
CHANGELOG.md
LICENSE
README.md
build.js
package-lock.json
package.json
schema.json

README.md

JSON schema for Angular service worker configuration file (ngsw-config.json)

Angular 8 update

My PR in Angular repo has been accepted and merged, so this feature is now directly available in Angular >= 8.0.0-beta.7. This lib is only useful in Angular 6 or 7.

By the same author

Why this lib?

@angular/service-worker is a very powerful tool to build Progressive Web Apps. The default service worker configuration file (ngsw-config.json) generated by the Angular CLI (either via ng add @angular/pwa or ng g service-worker) already takes care of saving permanently the static files of your application (index.html, JavaScript files...).

But you can go a lot further by adding dataGroups to save temporarily dynamic data (for example, your API calls, including images), which would be too big for localStorage or too difficult via indexedDB.

The official documentation explains it all, but as the ngsw-config.json file doesn't have a JSON schema, you don't get any assistance, and worse, mistakes are not always catched by the building system, so you could end up with errors in your production build.

So this lib is just the missing JSON schema for ngsw-config.json for productivity:

  • assistance,
  • no more errors!

Getting started

Install the lib (as a dev dependency):

npm install @ngx-pwa/ngsw-schema -D

Now you just have to add it to your ngsw-config.json file (of course, adapt the path to your case):

{
  "$schema": "../node_modules/@ngx-pwa/ngsw-schema/schema.json"
}

Changelog

Changelog available here.

License

MIT

You can’t perform that action at this time.