Skip to content

icefox0801/comment-toggle-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

comment-toggle-loader

Webpack loader for toggling javascript comment, avoiding hard code debug snippets in source code files.

Installation

npm i comment-toggle-loader -D

Usage

{
  test: /\.js$/i,
  loader: 'comment-toggle-loader',
  query: {
    enable: process.env.NODE_ENV === 'development'
  }
}

Webpack will replace

/* @debug@
console.info('Your debug info here');
*/

with

console.info('Your debug info here');

It will remove comment with query.match in development environment and do nothing in production environment. Meanwhile, the other comments not contain query.match will not be toggled.

Config

  • query.match: Comments with query.match will be toggled. Default is '@[\\w-]+@', which is a part of regular expression.
  • query.enable: Whether or not to enable comment toggling.

About

Webpack loader for toggling javascript comment

Resources

License

Stars

Watchers

Forks

Packages