ionic-team / ionic-pwa-toolkit

Build lightning fast Progressive Web Apps with zero config and best practices built-in. Go from zero to production ready with Ionic and Stencil (Web Components).
MIT License
633 stars 74 forks source link

Remove the custom service worker #96

Closed simonhaenisch closed 5 years ago

simonhaenisch commented 5 years ago

As discussed with @adamdbradley, this removes the custom service worker code, and relies on the default service worker instead that is generated using Workbox (generateSW mode).

See https://github.com/ionic-team/stencil-site/pull/246.

peterpeterparker commented 5 years ago

@simonhaenisch as the outputTargets has been remove from the config, is it still possible to avoid the use of service worker by settings its value to false?

like

export const config: Config = {
    outputTargets: [
        {
            type: 'www',
            serviceWorker: false
        }
    ],

while developing its really useful to have no service worker cache active

simonhaenisch commented 5 years ago

@peterpeterparker not sure what you mean? outputTargets is still in the config (line 6):

https://github.com/ionic-team/ionic-pwa-toolkit/blob/1aa8d205eff542ce51868db78aa2835b3bf975c2/stencil.config.ts#L5-L9

What's different after this PR here is that the custom service worker (src/sw.js) has been removed. That means that the default behavior will take place, which is to auto-generate a service worker with good defaults.

When you run Stencil in development mode, e. g. stencil build --dev --watch --serve, there is no service worker generated by default... there is a --service-worker CLI flag to force-enable it during dev mode though (see this file).

If you want to disable the service worker for your prod build as well, then yeah you can still just set serviceWorker: false or serviceWorker: null and it'll be disabled entirely.

peterpeterparker commented 5 years ago

All clear, thx a lot @simonhaenisch for the clear explanation, it answers my question