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 🙏

© 2025 – Pkg Stats / Ryan Hefner

stylesnap

v1.0.1

Published

Stylesnap is a powerful CSS optimization tool that analyzes your content files, extracts used classnames and tags, and generates a minimal CSS file. Ideal for reducing CSS file size and improving web performance in TailwindCSS, Bootstrap, or custom framew

Downloads

135

Readme

Stylesnap

Features

  • Extracts class names and tags from your HTML/JSX files.
  • Optimizes and minimizes CSS files based on your usage.
  • Supports custom configuration via stylesnap.config.json.
  • Works seamlessly with frameworks like Bootstrap, TailwindCSS, and custom CSS.
  • Generates a minified CSS file for better performance.

Installation

Install Stylesnap as a development dependency using npm:

npm install stylesnap --save-dev

Alternatively, use npx to run it directly:

npx stylesnap

Usage

Stylesnap can be used via the command line. It supports multiple options for flexibility and customization.

Command-Line Options

npx stylesnap [options]

Options:

  • --init

    • Initializes the configuration file stylesnap.config.json.
    • Example:
      npx stylesnap --init
  • -c, --content <globPattern>

    • Glob pattern to specify content files to scan for class names and tags.
    • Example:
      npx stylesnap -c "./src/**/*.html"
  • -C, --css <cssPath>

    • Path to the main CSS file to optimize.
    • Example:
      npx stylesnap -C "./src/styles.css"
  • -d, --defaultCss <defaultCssPath>

    • Path to a default CSS file to include in the output.
    • Example:
      npx stylesnap -d "./src/default.css"
  • -o, --output <outputPath>

    • Path to save the generated optimized CSS file.
    • Example:
      npx stylesnap -o "./dist/optimized.css"
  • --minifyCss

    • Minifies the final CSS file for optimal performance.
    • Example:
      npx stylesnap --minifyCss

Configuration

Stylesnap uses a configuration file named stylesnap.config.json to customize its behavior. Below is an example configuration:

{
  "content": ["./src/**/*.html", "./src/**/*.jsx"],
  "css": "./node_modules/bootstrap/dist/css/bootstrap.css",
  "defaultCss": "./src/styles.css",
  "output": "./dist/optimized.css",
  "minify": true
}

Configuration Fields

  • content: An array of glob patterns to specify the content files where class names and tags are extracted.
  • css: Path to the main CSS file to optimize.
  • defaultCss: Path to the default CSS file to include in the output.
  • output: Path to save the generated CSS file.
  • minify: Boolean to indicate whether to minify the final CSS.

Example Workflow

  1. Initialize the configuration file:

    npx stylesnap --init
  2. Update stylesnap.config.json with your project-specific settings:

    {
      "content": ["./src/**/*.html", "./src/**/*.jsx"],
      "css": "./node_modules/bootstrap/dist/css/bootstrap.css",
      "defaultCss": "./src/styles.css",
      "output": "./dist/optimized.css",
      "minify": true
    }
  3. Run Stylesnap:

    npx stylesnap
  4. The optimized CSS file will be saved at the path specified in the output field (e.g., ./dist/optimized.css).

Benefits

  • Reduces CSS file size, improving page load speed.
  • Eliminates unused CSS, enhancing maintainability.
  • Works out of the box with popular CSS frameworks like Bootstrap and TailwindCSS.
  • Customizable to fit any project structure or requirement.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

Developed by Ravi Kishan ([email protected]).

Contributions

Contributions, issues, and feature requests are welcome! Feel free to open an issue or submit a pull request on the GitHub repository.


Start optimizing your CSS today with Stylesnap! 🚀