Comments (9)
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.
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.
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.
@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:
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.
@adammesa You probably need to delete the old service worker?
from next-pwa.
@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.
Thank you, @shadowwalker! I suppose you only enable PWA in dev mode when specifically debugging PWA?
from next-pwa.
Hi @adammesa it has nothing to do with the dependency.
When you runyarn dev
, it runnext
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 putdisable: process.env.NODE_ENV !== 'production'
to yourpwa
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.
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)
- Refused to create worker
- configurable Custom Worker path prefix HOT 1
- Custom Worker hash changes on every build HOT 1
- Unable to Identify Application Installation Status in iOS and Android using next-pwa HOT 2
- Error: next-pwa@npm:5.6.0 [19fba] doesn't provide @babel/core (p7b8fe), requested by babel-loader
- TS `paths` config (imports with "@-paths") does not work for imports in TS workers HOT 3
- graphql url not cached
- [PWA] Compile server - error Unexpected token in JSON at position 0
- 404 errors
- withPWA precaches on every route, but I want it to do that only on specific routes
- next pwa config override next config: Experimental ServerMinify HOT 2
- push notification error in nextjs
- Property 'workbox' does not exist on type 'Window & typeof globalThis'.ts(2339) HOT 6
- Non-stop refresh on offline mode HOT 2
- How to use next-pwa with axiom and the bundle analyzer in esm HOT 3
- worker.ts with next-pwa does not create sw.js
- Service worker gets changed every build (output not reproducible)
- Disable media download src in background
- Last release was in Dec 18, 2022, please use DuCanhGH/next-pwa HOT 4
- deprecated packages on npm install for nextjs 14.1.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-pwa.