ionic-pwa-toolkit icon indicating copy to clipboard operation
ionic-pwa-toolkit copied to clipboard

service worker - not being generated

Open ashishtilara opened this issue 6 years ago • 1 comments

when I run

npm init stencil ionic-pwa

the generated code doesn't have service worker file, or package.json doesn't have any mention of start.sw in scripts, is there anything I am missing?

ashishtilara avatar Sep 25 '19 11:09 ashishtilara

@ashishtilara there is a file called stencil.config.ts with the following code:

` import { Config } from '@stencil/core';

// https://stenciljs.com/docs/config

export const config: Config = { outputTargets: [{ type: 'www', serviceWorker: null }], globalScript: 'src/global/app.ts', globalStyle: 'src/global/app.css' }; `

If you press CTRL + left mouse button you will see that exists a ServiceWorkerConfig that you can use.

I just change my stencil.config.ts to the following code and the build generate a sw.js

import { Config } from '@stencil/core';

// https://stenciljs.com/docs/config

export const config: Config = { outputTargets: [{ type: 'www', serviceWorker: { cacheId:'v1', } }], globalScript: 'src/global/app.ts', globalStyle: 'src/global/app.css' }; It will be nice if Stencil team improves the service worker docs to give us examples of configurations and examples of service worker features like push notifications and backgroud sync

rafaelbatistamarcilio avatar Nov 03 '19 04:11 rafaelbatistamarcilio