0.1.5 • Published 11 months ago

babel-plugin-helper-debug v0.1.5

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

babel-plugin-helper-debug

a babel plugin for debug

why

Sometimes we need to write some logic code in some environment.This plugin is to solve this problem.

Install

npm i babel-plugin-helper-debug

Usage

babel.config.js

options

  • varName: variable name,default('__DEBUG__')
  • remove: removable,default(false)
// babel.config.js

module.exports = {
  plugins: [
    [
      "helper-debug",
      { varName: "__DEBUG__", remove: process.env.NODE_ENV === "production" },
    ],
  ],
};

in you code

if (__DEBUG__) {
  // for debug
  console.log("debug test");
}

when you use eslint

// .eslintrc.js
module.exports = {
  globals: {
    __DEBUG__: true,
  },
};