Is it possible to removeConsole
in production only?
#34810
-
With the current next config, all console outputs are hidden. I wonder if it is possible to show console in development but hide in production. Thanks!
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 6 replies
-
Hello. You could enable it depending on the module.exports = {
compiler: {
removeConsole: process.env.NODE_ENV === "production",
},
}; will remove console.* when doing |
Beta Was this translation helpful? Give feedback.
-
For some reason this is not working on heroku using The console.logs are still present... Does anyone knows the issue? This is my next.config.js const nextConfig = {
reactStrictMode: true,
compiler: {
removeConsole: true
}
} excerpt from package.json {
"next": "12.0.7",
"next-auth": "^4.0.6",
"next-connect": "^0.11.0",
"next-remove-imports": "^1.0.6",
"next-seo": "^5.5.0",
"raw-body": "^2.5.1",
"react": "17.0.2",
} |
Beta Was this translation helpful? Give feedback.
-
Note: Since the root directory has .babelrc or bable.config.js in it, it will overwrite some of the configurations in next.config.js, so removeConsole will not take effect. https://nextjs.org/docs/architecture/nextjs-compiler#unsupported-features |
Beta Was this translation helpful? Give feedback.
-
Hello! These |
Beta Was this translation helpful? Give feedback.
-
is there any option to remove tried babel's |
Beta Was this translation helpful? Give feedback.
Hello.
You could enable it depending on the
NODE_ENV
value.will remove console.* when doing
yarn build
but will still keep them onyarn dev
.