Registry / devops / webpack-clear-console

webpack-clear-console

JSON →
library1.0.3jsnpmunverified

webpack-clear-console is a Webpack plugin that removes console statements from the bundle during compilation. Version 1.0.3 (latest) is stable with no recent updates. It provides a comment-based exclusion mechanism (/*NotClearConsole*/) to preserve specific console calls. Compared to similar plugins like babel-plugin-transform-remove-console or terser-webpack-plugin drop_console option, this plugin offers finer control per statement, though it only supports Webpack 4+ and requires manual comment annotations. No TypeScript types are included.

npm install webpack-clear-console
INSTALL
IMPORT
SIG · WEBPACK-CLEAR-CONS
W
webpack-clear-console
devopsjavascriptv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WebpackClearConsole
✓ const { WebpackClearConsole } = require('webpack-clear-console'); // or import { WebpackClearConsole } from 'webpack-clear-console';
✗ const WebpackClearConsole = require('webpack-clear-console');
The package exports an object with WebpackClearConsole as a property; destructuring is required.
default import
✓ import { WebpackClearConsole } from 'webpack-clear-console';
✗ import WebpackClearConsole from 'webpack-clear-console';
The package does not have a default export. Use named import.
require with wrong property
✓ const { WebpackClearConsole } = require('webpack-clear-console');
✗ const WebpackClearConsole = require('webpack-clear-console').default;
No default export exists; accessing .default results in undefined.

Basic Webpack config that removes all console statements from the output bundle using WebpackClearConsole.

// webpack.config.js const { WebpackClearConsole } = require('webpack-clear-console'); module.exports = { mode: 'production', entry: './src/index.js', output: { filename: 'bundle.js', path: __dirname + '/dist', }, plugins: [ new WebpackClearConsole(), ], };
Debug
Known issues
gotchaThe comment /*NotClearConsole*/ must be placed on the same line as or immediately after the console statement to preserve it.
fix
Add /*NotClearConsole*/ on the same line as console.log('keep me');.
affects: >=1.0.0
gotchaOnly statements that start with console. are removed. Member expressions like Array.prototype.console are not affected.
fix
Ensure all console calls begin with console. to be removed.
affects: >=1.0.0
gotchaWorks only with Webpack 4+; plugin API may be incompatible with older Webpack versions.
fix
Upgrade to Webpack 4 or later.
affects: >=1.0.0
breakingThe plugin removes all console calls regardless of severity (log, warn, error, etc.). There is no option to filter by console method.
fix
If selective removal is needed, consider using a custom loader or babel-plugin-transform-remove-console.
affects: >=1.0.0
deprecatedThe package has not been updated since 2018; Webpack 5 compatibility is not tested.
fix
Test with Webpack 5; if broken, use an alternative like terser-webpack-plugin drop_console.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: WebpackClearConsole is not a constructor
Importing the package without destructuring; using require('...') returns an object, not the constructor.
fix
Use const { WebpackClearConsole } = require('webpack-clear-console'); then new WebpackClearConsole();
Module build failed: Error: Cannot find module 'webpack-clear-console'
Package not installed or npm link issue.
fix
Run npm install webpack-clear-console --save-dev
console.log statements are not removed in production build
Plugin not added to plugins array or Webpack config mode not set to production.
fix
Add new WebpackClearConsole() to plugins array in webpack.config.js.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
webpack-clear-console — npm install webpack-clear-console · libregistry