npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

remove-comments-plugin

v1.0.0-beta-3

Published

A tool to remove comments from JavaScript, CSS, and HTML files

Readme

remove-comments-plugin

A powerful tool to remove comments from JavaScript, CSS, and HTML files, with support for version information filtering.

Installation

npm install remove-comments-plugin

Usage

Command Line

# Use default configuration
remove-comments

# Specify directory
remove-comments --distPath ./dist

# Specify file types
remove-comments --fileTypes .js,.css,.html

# Specify filename filtering patterns
remove-comments --fileIncludePatterns chunk-vendors,app

# Specify version information filtering patterns
remove-comments --versionPatterns Vue.js,vuex

# Disable verbose logging
remove-comments --verbose false

Package.json Scripts

Configure scripts in package.json for easy use in projects:

{
  "scripts": {
    "remove-comments": "remove-comments --distPath ./unpackage/dist/build/h5 --versionPatterns Vue.js,vuex"
  }
}

Then run:

npm run remove-comments

Programmatic Usage

const { main, removeJavaScriptComments, removeCssComments, removeHtmlComments } = require('remove-comments-plugin');

// Use default configuration
main();

// Use custom configuration
main({
    distPath: './dist',
    fileTypes: ['.js', '.css'],
    fileIncludePatterns: ['chunk-vendors'],
    verbose: true,
    versionPatterns: ['Vue.js v2.6.11', 'vuex v3.6.2']
});

// Use comment removal functions individually
const jsCode = '// This is a comment\nconsole.log("Hello World");';
const cleanJsCode = removeJavaScriptComments(jsCode);

const cssCode = '/* This is a comment */\nbody { margin: 0; }';
const cleanCssCode = removeCssComments(cssCode);

const htmlCode = '<!-- This is a comment -->\n<div>Hello World</div>';
const cleanHtmlCode = removeHtmlComments(htmlCode);

Features

  • Removes comments from JavaScript, CSS, and HTML files
  • Supports custom directory paths
  • Supports custom file types
  • Supports custom filename filtering patterns
  • Supports version information filtering (only removes comments containing specific version patterns)
  • Provides detailed logging
  • Can be used both as a command-line tool and as a library
  • Compatible with Node.js 10 and above

Configuration Options

| Option | Short | Description | Default | | ------ | ----- | ----------- | ------- | | distPath | -d | The directory path to process | ./dist | | fileTypes | -t | An array of file extensions to process | ['.js'] | | fileIncludePatterns | -p | An array of filename patterns to filter files | ['chunk-vendors', 'app'] | | versionPatterns | -V | An array of version patterns to filter comments | ['Vue.js', 'vuex'] | | verbose | -v | Whether to print detailed logs | true |

Common Issues and Solutions

1. Directory Not Found Error

Error message:

Error: Directory does not exist - ./dist
Please run the build command first to generate the directory

Solution:

  • Ensure you have run the build command to generate the target directory
  • Check that the directory path is correct

2. Plugin Not Found Error

Error message:

'remove-comments' is not recognized as an internal or external command, operable program or batch file.

Solution:

  • Ensure the remove-comments-plugin dependency is correctly installed
  • Try using npx remove-comments instead

3. Comments Not Removed

Error message:

Processing completed: xxx.js, removed 0 characters of comments

Solution:

  • Check if the version information comments contain the specified keywords (e.g., Vue.js or vuex)
  • Check if the files match the filename filtering patterns

Complete Workflow

  1. Install the plugin: npm install remove-comments-plugin
  2. Configure the plugin in package.json or use it directly via command line
  3. Run your build process (e.g., HBuilderX build)
  4. Run the plugin to remove version information comments
  5. Deploy the processed files

Notes

  • Ensure the target directory exists before running the plugin
  • The plugin only removes comments containing specified version information, not other comments
  • If you need to modify filtering rules, adjust the script parameters in package.json
  • For more detailed information, refer to the project documentation

License

MIT