This task removes all console logging statements from your source code.
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 is the path to
your source file and
dest is the file this task will write to (relative to the
An example configuration looks like this:
To run this task against multiple files and automatically overwrite them
with the resultant output, omit the
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
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
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
logmethods, but keep
You can tell this task to keep specific logging statements by adding the comment directive
/*RemoveLogging:skip*/ after the statement:
console;/*RemoveLogging:skip*/// or:console/*RemoveLogging:skip*/;// whitespace is fine too, whatever floats your boat:console /* RemoveLogging:skip */;