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

package-minifier

v1.0.3

Published

Minify JS, CSS, and HTML while preserving folder structure

Readme

📂 Package Minifier

Recursively Minify/Uglify JS, CSS, and HTML Files in a Directory While Preserving Folder Structure!

✨ Features

✅ Minify/Uglify JavaScript files (with uglify-js)
✅ Minify CSS files (with clean-css)
✅ Minify HTML files (with html-minifier-terser)
✅ Preserve original folder structure
✅ Highly configurable via package-minifier.config.js or package-minifier.config.ts
✅ Exclude specific files or folders
✅ Simple CLI interface
✅ Works recursively across folders

📦 Installation

npm install --save-dev package-minifier

🚀 Usage

After installation, you can run it from any directory under your project:

npx pkgmin

By default, it will:

  1. Use the current working directory as the input folder.
  2. Look for a config file named package-minifier.config.js in the current working directory (or use the default configuration).

🔧 Configuration

Place a file called package-minifier.config.js (or package-minifier.config.ts) in the root of your project directory.

Basic Example (package-minifier.config.js)

import {defineConfig} from "package-minifier";

export default defineConfig({
    excludeFiles: ["ignore.js", "skip-this.html"],
    excludeFolders: ["node_modules", "tests"],
    outputDir: "minified",

    html: {
        enabled: true,
        options: {
            collapseWhitespace: true,
            removeComments: true,
            minifyCSS: true,
            minifyJS: true
        }
    },
    css: {
        enabled: true,
        options: {
            level: 2
        }
    },
    js: {
        enabled: true,
        options: {
            compress: {
                drop_console: true
            },
            mangle: true,
            output: {
                comments: false
            }
        }
    }
});

📁 How It Works

| Step | What Happens | | ---- | ------------------------------------------------------------ | | 1 | Recursively traverses files in the current working directory | | 2 | Minifies JS, CSS, and HTML based on your config options | | 3 | Copies other file types unchanged | | 4 | Preserves the original folder structure | | 5 | Outputs everything into the outputDir directory |

🛠 Options Explained

| Option | Type | Description | | ---------------- | ---------- | --------------------------------------------------------------------------------------- | | excludeFiles | string[] | List of files to exclude | | excludeFolders | string[] | List of folders to exclude (recursively) | | outputDir | string | Output directory path (relative to current working dir) | | js.enabled | boolean | Enable/disable JS minification/uglification | | js.options | object | Options passed to uglify-js (see docs) | | css.enabled | boolean | Enable/disable CSS minification | | css.options | object | Options passed to clean-css (see docs) | | html.enabled | boolean | Enable/disable HTML minification | | html.options | object | Options passed to html-minifier-terser (see docs) |

✅ Example Folder Structure

project/
├── src/
│   ├── index.html
│   ├── style.css
│   └── scripts/
│       └── app.js
├── package-minifier.config.js
└── minified/    <-- outputDir (generated)

✅ Contributing

Pull requests are welcome! Here's how to contribute:

  1. Fork the repo
  2. Create a new branch
  3. Commit your changes
  4. Submit a PR 🚀

✅ License

MIT License © Syed Abdullah