sw.js not created when installing

atmar
46
atmar
commented a year 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
758
aldarund
commented a year ago

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

0
flaviocordova
0
flaviocordova
commented 10 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 10 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 8 months ago

+1

0
alinasuciu
0
alinasuciu
commented 7 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 7 months ago

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

0
simllll
31
simllll
commented 6 months 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
5.0k
manniL
commented 6 months ago

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

0
aldarund
758
aldarund
commented 6 months 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
280
kevinmarrec
commented 6 months 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
5.0k
manniL
commented 6 months 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
hendriksenremco
0
hendriksenremco
commented 3 months 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

This is indeed confusing. Maybe this should be mentioned in the documentation

0
pi0
28.0k
pi0
commented 3 months ago

@hendriksenremco A PR for mentioning in docs would be more than welcome ❤️ static dir should be deployed as well.

0
Informations
QuestionUnresolved
#c28 - Created a year ago