This is my configuration:
Angular CLI: 8.2.1
Node: 10.15.2
OS: win32 x64
Angular: 8.2.1
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.802.1
@angular-devkit/build-angular 0.802.1
@angular-devkit/build-optimizer 0.802.1
@angular-devkit/build-webpack 0.802.1
@angular-devkit/core 8.2.1
@angular-devkit/schematics 8.2.1
@angular/cdk 8.1.2
@angular/material 8.1.2
@angular/pwa 0.802.1
@ngtools/webpack 8.2.1
@schematics/angular 8.2.1
@schematics/update 0.802.1
rxjs 6.4.0
typescript 3.5.3
webpack 4.38.0
I ran ng add @angular/pwa
. It created the following ngsw-config.json:
{
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/*.css",
"/*.js"
]
}
}, {
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
]
}
}
]
}
My package.json contains:
"@angular/pwa": "^0.802.1",
"@angular/service-worker": "~8.2.0",
My angular.json contains:
"serviceWorker": true,
"ngswConfigPath": "ngsw-config.json"
This is my manifest.webmanifest:
{
"name": "postit",
"short_name": "postit",
"theme_color": "#1976d2",
"background_color": "#fafafa",
"display": "standalone",
"scope": "/",
"start_url": "/",
"icons": [...]
}
I build using ng build --prod
and deploy on my web server.
I get a No matching service worker detected
warning:
When I turn to offline mode:
What did I miss so that offline mode works?
When doing the PWA testing on a non-localhost server you want to make sure it is HTTPS.
That is a core requirement.