Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including grunt-remove-logging with all npm packages installed. Try it out:

var gruntRemoveLogging = require("grunt-remove-logging")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

grunt-remove-logging v0.2.0

Grunt task to remove console logging statements


This task removes all console logging statements from your source code.

Getting Started

Install this plugin with the command:

npm install grunt-remove-logging

Next, add this line to your project's grunt file:


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


This task has two required properties, src and dest. src is the path to your source file and dest is the file this task will write to (relative to the grunt.js file).

An example configuration looks like this:

  removelogging: {
    dist: {
      src: "js/application.js",
      dest: "js/application-clean.js",

      options: {
        // see below for options. this is optional.

To run this task against multiple files and automatically overwrite them with the resultant output, omit the dist option:

  removelogging: {
    dist: {
      src: "dist/**/*.js" // Each file will be overwritten with the output!

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.

Skipping 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 */;
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free