sandoche / Darkmode.js

🌓 Add a dark-mode / night-mode to your website in a few seconds
https://darkmodejs.learn.uno
MIT License
2.72k stars 176 forks source link

Problem with Next/Nuxt.js #15

Closed shuffgy closed 4 years ago

shuffgy commented 5 years ago

Hey, as mentioned via mail is here the issue.

While integrating in my next.js-App its working fine with the widget. But if i dont use the widget, it breaks the app with "window not defined".

Your answer:

I had the same problem with Nuxt.js (the equivalent of Next for Vue.js) I guess it's typical because Next/Nuxt is trying to render it.

I need to investigate on it. I am a bit busy these days I may try in the next two weeks. Please open an issue on github so I don't forget!

so, here it is :D

Thank you very much!

frencojobs commented 5 years ago

I guess this happens when the bundler outside of browsers, don't know how to treat the window object. The same thing can happens when building with gatsby. The problem can easily be solved by changing window to this in the moulde file's lib/darkmodejs-js. If you want to use in production, you might need this to be originally fixed by the library. (Report to library authors)

P.S. I don't know the side effects of editing the file, and other relating errors. It just fixed for me.