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
635 stars 74 forks source link

Disappearing sw.js file and service worker in browser #57

Closed cnhnet closed 6 years ago

cnhnet commented 6 years ago

Resources: Before submitting an issue, please consult our docs.

Stencil version: (run npm list @stencil/core from a terminal/cmd prompt and paste output below):

@stencil/core v0.7.24

I'm submitting a ... (check one with "x") [ X] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://stencil-worldwide.slack.com

Current behavior: I'm not sure if I am misunderstanding something in the newest PWA toolkit, but sometimes when I run "npm run devWithSW" it deletes the sw.js file from the build and there is no service worker loaded in the browser. To get the sw.js back, I have to re-build ("npm run build"). But, after I rebuild and run "npm run devWithSW", it deletes the sw.js again.

Here is the sw.js in the www folder after build: 0 after build

Note the sw.js is gone from the www folder after "npm run devWithSW": 1 after devwithsw

Note that there is no service worker in the browser after "npm run devWithSW": 2 after devwithsw

Expected behavior: I expect the sw.js to be there everytime after running "npm run devWithSW" so that a service worker is properly loaded in the browser.

Steps to reproduce: Using Visual Code for the Ionic PWA Toolkit, run build. Note the sw.js file in the build folder (www). Now, run devWithSW and note how the sw.js is deleted and that there is no service worker loaded in the browser. This does not occur eveytime, but enough times where you should be able to replicate it after a few tries.

Related code:

insert any relevant code here

Other information:

kael commented 6 years ago

Mentioned also in https://github.com/ionic-team/stencil/issues/789

jgw96 commented 6 years ago

Closing this on favor of the linked stencil issue. Thanks everyone!