1.0.3 • Published 3 years ago

babel-plugin-dev-log v1.0.3

Weekly downloads
67
License
MIT
Repository
-
Last release
3 years ago

babel-plugin-dev-log

helps developers debug and log output in the development environment

Install

npm

 npm install babel-plugin-dev-log

yarn

yarn add babel-plugin-dev-log

Usage

  1. Configure the .eslintrc.js file

    module.exports = {
      // Omit other configuration items
      globals: {
        __DEV__: true
      }
    }
  2. The Babel configuration file(such as .babelrc.js

    module.exports = {
      // Omit other configuration items
      plugins: [['dev-log']]
    }
  3. Output in the project

    if (__DEV__) {
      console.log("This log is printed only in the development environment. Production ignores if(__DEV__){...} block")
    }

Options

NameTypeDefaultDescription
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.