Removes console logging statements.

Downloads in past


641.2.07 years ago7 years agoMinified + gzip package size for gulp-remove-logging in KB


Build Status Test Coverage NPM Downloads Gitter
Removes all console logging statements from your code.
This plugin is based on the initial work of @ehynds on grunt-remove-logging.

Getting Started

Install this plugin with the command:
npm install gulp-remove-logging

Next, add this line to your gulpfile:
var gulp_remove_logging = require("gulp-remove-logging");

Lastly, add the configuration settings (see below) to your gulpfile.

Task Configuration

gulp.task("remove_logging", function() {
  return gulp.src("src/javascripts/**/*.js")
        // Options (optional)
        // eg:
        // namespace: ['console', 'window.console']

Optional Configuration Properties

This plugin can be customized by specifying the following options:
  • replaceWith: A value to replace logging statements with. This option defaults to an empty string. If you use fancy statements like console && console.log("foo");, you may choose to specify a replaceWith value like 0; so that your scripts don't completely break.
  • namespace: An array of object names that logging methods are attached to.
Defaults to [ 'console', 'window.console' ]. If you use a custom logger, like MyApp.logger.log(foo), you would set this option to [MyApp.logger].
  • methods: An array of method names to remove. Defaults to all the methods in the Firebug console API. This option is useful if you want to strip out all log methods, but keep warn for example.
  • verbose: Boolean value, whether to show count of logging statements removed for each file. Defaults to true. If false, a single summary line is logged to gulp instead.

Skip Individual Statements

You can tell this task to keep specific logging statements by adding the comment directive /*RemoveLogging:skip*/ after the statement:

// or:


// whitespace is fine too, whatever floats your boat:

console.log("foo") /* RemoveLogging:skip */;