babel-plugin-transform-remove-console

Example

In

  1. console.log("foo");
  2. console.error("bar");

Out

Installation

  1. npm install babel-plugin-transform-remove-console --save-dev

Usage

.babelrc

  1. // without options
  2. {
  3. "plugins": ["transform-remove-console"]
  4. }
  1. // with options
  2. {
  3. "plugins": [ ["transform-remove-console", { "exclude": [ "error", "warn"] }] ]
  4. }

Via CLI

  1. babel --plugins transform-remove-console script.js

Via Node API

  1. require("@babel/core").transform("code", {
  2. plugins: ["transform-remove-console"]
  3. });

Options

  • exclude - An array of console methods to exclude from removal.

You can read more about configuring plugin options here