Closed marlass closed 5 years ago
Double-check with Tobias first
We discussed this as part of the PWA PR. Filip and I thought it was a good idea. With @znikola and @dunqan we came up with a working solution for this.
PR #223
To test, first run the following: yarn build:core:lib
, yarn build
and yarn start:pwa
.
Open the devtools and verify that SW is running. You can also toggle offline mode and refresh - you should see part of the page that was cached and is served from the SW.
After this, stop the app, and change the config in app.module.ts
to:
...
pwa: {
enabled: false,
...
}
...
Start the app again (yarn start:pwa
), navigate to chrome's devtools application
tab, clear everything, and refresh the page. Now, make sure that the SW is not running. Note: the SW will probably appear in the list, but it shouldn't be marked as running.
If you toggle the offline switch again, and refresh, you should see the chrome's offline dinosaur.
Docs update proposal for: https://github.com/SAP/cloud-commerce-spartacus-storefront/pull/50#issuecomment-438271972
Set pwa.enabled
and pwa.addToHomeScreen
config to true
in StorefrontModule
configuration
StorefrontModule.withConfig({
production: environment.production,
server: {
baseUrl: environment.occBaseUrl
},
pwa: {
enabled: true,
addToHomeScreen: true
}
})
Note that production
flag in the StorefrontModule
's config has to also be set to true
.
Follow-up doc ticket GH-279 updated to include reference to doc input provided here. Thanks, @znikola ! 😄
It would be good if all PWA configuration will be placed inside
StorefrontModule
. Currently, we need to includeServiceWorkerModule
besideStorefrontModule
on app root. Look at PR #50 for more information.