sw.js 404 for me too with nuxt-edge after nuxt build.
I'm trying pwa-module now and I'm a little lost here (that is, I'm not sure if I'm missing something or just found a bug.. 😃 )
I think/believe sw.js should be created on build time to point to the current files recently generated, isn't that ? It's working just like that for OneSignal files...
I had a sw.js file but it imported an invalid script (what I thought was a bug also)... then I removed sw.js, hoping It would generate but it's not generated again...
I have this configuration:
modules: [
'@nuxtjs/pwa',
'@nuxtjs/onesignal',
...
],
manifest: {
name: 'MyTestApp,
description: 'Testing PWA App'
},
workbox: {
dev: true,
debug: true
},
oneSignal: {
init: {
appId: process.env.ONE_SIGNAL_ID || 'foobar',
allowLocalhostAsSecureOrigin: true,
welcomeNotification: {
disable: false
}
}
},
...
Any idea?
Did anyone ever figure this out? I'm getting load failures on onesignal scripts. Can't determine if they're related to the fact that no sw.js file is generated.
+1
Hi guys! did you tried to create manually static/sw.js (empty) file? https://pwa.nuxtjs.org/setup
I had the same issue, but after doing a npm run generate a sw.js was created.
Same issue here too.. interesting, I had one locally, but on my deployment (where gitignore is used that this file does not exist), it's never created. Just tested it locally gain, removed the sw.js file, and started npm run build => no sw.js file has been created? Is there a different approach to generate this file now?
Can somebody narrow it down to a specific version or commit?
I suspect some of confusion in this ticket might be due to fact that sw.js generated inside static folder, not in .nuxt/dist
Had this issue around my app deployement through a CI Pipeline, cause I wasn't telling to my Pipeline job to cache/artifact the static folder but only node_modules & .nuxt, so the generated sw.js wasn't here in my deployment step (as @aldarund said, the sw.js will result in static and not .nuxt/dist). Fixed it simply adding the static folder in the saved artifacts between my jobs (I'm using GitLab CI)
Good catch @aldarund and @kevinmarrec!
Closing the issue :relaxed:
The service worker (sw.js) file will be created directly in the static file. You might have to copy it over if you have a deploy pipeline.
I suspect some of confusion in this ticket might be due to fact that sw.js generated inside static folder, not in .nuxt/dist
This is indeed confusing. Maybe this should be mentioned in the documentation
@hendriksenremco A PR for mentioning in docs would be more than welcome :heart: static dir should be deployed as well.
Kind of late here, but I've just had a similar experience, getting 404 for sw.js when deploying on Now. I was using the now.json model found on Nuxt docs — Service Worker with Nuxt PWA Module.
It turned out that it worked with the basic settings instead:
{
"version": 2,
"builds": [
{
"src": "nuxt.config.js",
"use": "@nuxtjs/now-builder",
"config": {}
}
]
}
Most helpful comment
I suspect some of confusion in this ticket might be due to fact that sw.js generated inside static folder, not in .nuxt/dist