Giter VIP home page Giter VIP logo

Comments (9)

paales avatar paales commented on May 19, 2024 6

In your config you can do something like this to disable the generation in development mode:

      pwa: {
        disable: process.env.NODE_ENV !== 'production',
      }

Maybe that would be a good default, for the module, or is it advised to run with a service worker in development?

from next-pwa.

shadowwalker avatar shadowwalker commented on May 19, 2024 3

Hi @adammesa it has nothing to do with the dependency.
When you run yarn dev, it run next command in dev mode, which is using the webpack watch mode.
Yes, sw.js do get generated repeatedly if pwa is not disabled. The reason behind that is sometimes people want to debug certain features in dev mode (such as web push).
You can simply put disable: process.env.NODE_ENV !== 'production' to your pwa configuration to disable it in dev mode.
Remember clear all cache data and reload first when you couldn't figure out the issue.

from next-pwa.

adammesa avatar adammesa commented on May 19, 2024

I also get this error in my console:

webpack.js?__WB_REVISION__=90450aec28871796918b3a8200e705c9:83 GET http://localhost:3000/_next/static/webpack/c2b41ab35ca3098117e1.hot-update.json 404 (Not Found)

from next-pwa.

adammesa avatar adammesa commented on May 19, 2024

@paales that did fix the bug, yes, but as a result PWA is fully disabled and my app is now a blank screen, even when visiting not in a browser. This is what it looks like without the disable: process.env.NODE_ENV !== 'production' line:
image

Most of the development stuff it's doing there, like disabling the cache and precache, is good. I can't help but wonder if GenerateSW is being called repeatedly because I had to make my pwa file look like:

const withPWA = require('next-pwa');
 
module.exports = withPWA({
  // other next config
  pwa: {
      dest: 'public',
  }
})

and then in my NextJS public/ folder, add a static/ folder to contain my manifest.json

from next-pwa.

paales avatar paales commented on May 19, 2024

@adammesa You probably need to delete the old service worker?

from next-pwa.

adammesa avatar adammesa commented on May 19, 2024

@paales unfortunately that doesn't seem to be it! I think I finally understand the error a bit more. When I was updating the next & next-pwa, I got the following error:

warning " > [email protected]" has unmet peer dependency "webpack@>=4.0.0".
warning "next-pwa > [email protected]" has unmet peer dependency "webpack@*".
warning "next-pwa > [email protected]" has unmet peer dependency "webpack@^4.0.0".

It sounds like next-pwa is piggy-backing off another one of my plugins which might have webpack in --watch mode...

from next-pwa.

adammesa avatar adammesa commented on May 19, 2024

Thank you, @shadowwalker! I suppose you only enable PWA in dev mode when specifically debugging PWA?

from next-pwa.

vinkovsky avatar vinkovsky commented on May 19, 2024

Hi @adammesa it has nothing to do with the dependency.
When you run yarn dev, it run next command in dev mode, which is using the webpack watch mode.
Yes, sw.js do get generated repeatedly if pwa is not disabled. The reason behind that is sometimes people want to debug certain features in dev mode (such as web push).
You can simply put disable: process.env.NODE_ENV !== 'production' to your pwa configuration to disable it in dev mode.
Remember clear all cache data and reload first when you couldn't figure out the issue.

Hi @shadowwalker! Could you please explain to me if it is possible to disable sw.js generation in development mode? Your advice is to add `disable: process.env.NODE_ENV! == 'production' 'doesn't seem to fix lags

from next-pwa.

laclance avatar laclance commented on May 19, 2024

never got this warning the first time I ran yarn dev but now I get it multiple time even after deleting .next folder, sw and workbox files, clearing all cache and doing a hard refresh.

from next-pwa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.