正在加载视频...

视频加载失败

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

146,413 次观看 • 1 年前 •via X (Twitter)

10 条评论

Alex Sidorenko 的头像
Alex Sidorenko1 年前

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:

Ninio 的头像
Ninio1 年前

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 🚀

Prakhar Shukla 的头像
Prakhar Shukla1 年前

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

Malvin 🇬🇭 的头像
Malvin 🇬🇭1 年前

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

Prasenjit 的头像
Prasenjit1 年前

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

pankaj 的头像
pankaj1 年前

but we test on prod

Adil - medusa/acc - oss/acc 的头像
Adil - medusa/acc - oss/acc1 年前

simple and efficient 🙌

⅃ ℺ ℇ 💀 的头像
⅃ ℺ ℇ 💀1 年前

but then how will we debug in prod?

Frank Flitton 的头像
Frank Flitton1 年前

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

Jordan Hall 的头像
Jordan Hall1 年前

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

相关视频