Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

You can remove all console calls from prod in Next.js

146,413 Aufrufe • vor 1 Jahr •via X (Twitter)

10 Kommentare

Profilbild von Alex Sidorenko
Alex Sidorenkovor 1 Jahr

Note that it removes all console calls both from the client and the server in prod. You can exclude specific methods if you want to keep them:

Profilbild von Ninio
Niniovor 1 Jahr

One level higher is introducing a `INTERNAL_ENV` environment variable, which is `dev`, `stage` or `prod`. And then you can have the console.log's showing up in staging, but not on production 🚀

Profilbild von Prakhar Shukla
Prakhar Shuklavor 1 Jahr

shouldn’t your linter handle this? Have a linting job that removes console logs.

Profilbild von Malvin 🇬🇭
Malvin 🇬🇭vor 1 Jahr

Yes! I’ve been doing it all the way from v11. Next is super!

Profilbild von Prasenjit
Prasenjitvor 1 Jahr

That's super useful. Thank you for the share, Alex

Profilbild von pankaj
pankajvor 1 Jahr

but we test on prod

Profilbild von Adil - medusa/acc - oss/acc
Adil - medusa/acc - oss/accvor 1 Jahr

simple and efficient 🙌

Profilbild von ⅃ ℺ ℇ 💀
⅃ ℺ ℇ 💀vor 1 Jahr

but then how will we debug in prod?

Profilbild von Frank Flitton
Frank Flittonvor 1 Jahr

Woah that’s cool. Does that include stdout on the server too?

Profilbild von Jordan Hall
Jordan Hallvor 1 Jahr

This is kinda bad for any logging npm packages that override console logging

Ähnliche Videos