nuxt-community / pwa-module

Zero config PWA solution for Nuxt.js
https://pwa.nuxtjs.org
MIT License
1.23k stars 171 forks source link

Can't add custom service worker #467

Open artrayd opened 3 years ago

artrayd commented 3 years ago

Doing same as in docs

// nuxt.config.js
pwa: {
  workbox: {
    importScripts: ['custom-sw.js'],
  }
}
// static/custom-sw.js
console.log('Custom service worker!')

And nothing in console..

shot-codes commented 2 years ago

Are you testing using the development server yarn dev? If so try with yarn build and then yarn start. As per the docs

artrayd commented 2 years ago

Hi @TheFoolishPupil thank you for your answer, I tried to do as you said and there is still no message in console :(

Created also a sample at codesandbox.io. Please tell me what I'm doing wrong :)

https://codesandbox.io/s/youthful-sound-ifdo1?file=/nuxt.config.js

yinfoyuan commented 2 years ago

nuxt.config.js The server cannot be loaded after being modified

mamdasan commented 8 months ago

having the same issue here

mamdasan commented 8 months ago

my issue here is solved. the problem was i was running my nuxt build not with 127.0.0.1. the problem is other than this dns, the you need https so the browser will trust and run your service worker. this dns 127.0.0.1 is trusted by most browsers.