sw.js not created when installing

atmar
46
atmar
commented 9 months ago

Hello,

I keep receiving sw.js 404 not found. It's not in the static folder either with the install. Installed it with npm install.

0
aldarund
373
aldarund
commented 7 months ago

sw.js 404 for me too with nuxt-edge after nuxt build.

0
flaviocordova
0
flaviocordova
commented 5 months ago

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?

0
ndarilek
40
ndarilek
commented 4 months ago

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.

0
iplanwebsites
0
iplanwebsites
commented 2 months ago

+1

0
alinasuciu
0
alinasuciu
commented 2 months ago

Hi guys! did you tried to create manually static/sw.js (empty) file? https://pwa.nuxtjs.org/setup

0
ducdebreme
0
ducdebreme
commented a month ago

I had the same issue, but after doing a npm run generate a sw.js was created.

0
simllll
31
simllll
commented 12 days ago

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?

0
manniL
2.9k
manniL
commented 8 days ago

Can somebody narrow it down to a specific version or commit?

0
aldarund
373
aldarund
commented 8 days ago

I suspect some of confusion in this ticket might be due to fact that sw.js generated inside static folder, not in .nuxt/dist

0
kevinmarrec
0
kevinmarrec
commented 8 days ago

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)

0
manniL
2.9k
manniL
commented 7 days ago

Good catch @aldarund and @kevinmarrec!
Closing the issue ☺️

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.

0
Informations
QuestionUnresolved
#c28 - Created 9 months ago