pwa-module
pwa-module copied to clipboard
Can't add custom service worker
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..
Are you testing using the development server yarn dev
? If so try with yarn build
and then yarn start
. As per the docs
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
nuxt.config.js The server cannot be loaded after being modified
having the same issue here
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.