helps developers debug and log output in the development environment
npm install babel-plugin-dev-log
yarn add babel-plugin-dev-log
-
Configure the
.eslintrc.js
filemodule.exports = { // Omit other configuration items globals: { __DEV__: true } }
-
The Babel configuration file(such as
.babelrc.js
)module.exports = { // Omit other configuration items plugins: [['dev-log']] }
-
Output in the project
if (__DEV__) { console.log("This log is printed only in the development environment. Production ignores if(__DEV__){...} block") }
Name | Type | Default | Description |
---|---|---|---|
customIdentifier |
{String} |
__DEV__ |
Use a custom identifier. notes: The key value of the globals option in the .eslintrc.js file should be the same as the custom identifier. |
isProd |
{Boolean} |
process.env.NODE_ENV === "production" |
When isProd is true, remove if(__DEV__){...} block. Most applications are in the package build phase. |