nuxt-pwa-module: [Bug] No service worker detected

Hey,

Thanks for this module!

I have a question regarding the service worker as it does not seem to be registered by default.

image

My nuxt.config.ts

  pwa: {
    manifest: {
      name: 'Test',
      short_name: 'Test'
    },
    workbox: {
      enabled: true
    }
  },

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 32 (17 by maintainers)

Most upvoted comments

It wont be that easy πŸ˜„

Basically the issue was that the service worker was not generating. After I run the yarn build it started to work. I dont know it it is a vite cache deps or something else but now it works like a charm.

I think your explanation would be sufficient to fix the issue in the future πŸ˜ƒ

You can maybe include this issue and the result of it in some kind of FAQ section

@kevinmarrec

Reading this comment was a rolercoaster of dramatic action switches πŸ˜„

Awesome that you fixed it! ❀️

@Baroshem Even if something strange seems to happened with Nuxt 3 when opt-in the router (using pages folder), I think I need to implement the worker registration in another way to fix this.

EDIT: This can’t be fixed yet, it sounds that Vue Router makes window load events fired before Nuxt 3 plugin.

EDIT2: Found a fix, will be shipped in v0.3.0

Alright, thanks, I reproduced it.

It seems that this window event listener is never trigerred : https://github.com/kevinmarrec/nuxt-pwa-module/blob/aa01db1679eee3141d8576b24a62b3779f99960e/src/runtime/workbox/plugin.ts#L8

I’m wondering what is causing this to happen, most likely it can be two things :

  • The event is fired before it adds the event listener
  • Something prevents the event to be fired