dev-console.macro
This is a Babel macro to be used with babel-plugin-macros. By default, it'll remove all console.log
, console.warn
and console.error
calls from production
builds. Internally it uses babel-plugin-transform-remove-console.
Installation
npm install --save-dev dev-console.macro babel-plugin-macros
Usage
console// Removed in production & staging builds console// Removed in production builds const w = consolewarn// In production & staging, `w` will be defined as `function () {}`
Configuration
First of all, you'll need to have "macros"
included as a Babel plugin. In some environments like react-scripts 2.0 this will already be done for you; for more details please refer to the babel-plugin-macros documentation.
If you'd like to customise this macro's behaviour in specific environments and/or exclude specific methods of console
from being removed, set the value of the remove-console
key in your babel-plugin-macros config. The default config corresponds to this: