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

create-tailwind-safelist

v0.1.1

Published

Generates a Tailwind safelist.txt file from regex patterns.

Readme

Create Tailwind CSS Safelist

Are you missing your regex based safelist after upgrading to Tailwind CSS 4?

With this command-line tool, you can generate a text file containing all safelisted class values, based on your regex patterns.

This helps ensure that all necessary Tailwind classes are included in your production build, even those generated dynamically.

Features

  • Generates a list of Tailwind CSS classes based on provided regex patterns.
  • Supports patterns with alternatives (e.g., text-(blue|red)-500).
  • Provides a command-line interface for easy integration into your build process.
  • Allows specifying an output file.
  • Includes basic regex validation to prevent potentially dangerous patterns.

Usage

npx create-tailwind-safelist@latest <patternsFile> [options]
  • <patternsFile>: Path to a JavaScript file containing an array of regex patterns.

Options

  • -o, --output : Path to the output file (default: tailwind-safelist.txt).

Example patterns.js

module.exports = [
  '(sm:|md:|lg:)text-(blue|red)-500',
  '(hover:|)text-blue-500',
  'text\-blue', // Example with escaped hyphen
];

Generating the safelist

To generate the safelist, run the following command:

npx create-tailwind-safelist@latest ./patterns.js -o ./my-safelist.txt

This will read the patterns from patterns.js and write the generated safelist to my-safelist.txt. If you omit the -o option, the output will be written to tailwind-safelist.txt.

Integrating with Tailwind CSS

  1. Generate the safelist: Run create-tailwind-safelist to generate the tailwind-safelist.txt file.
  2. Configure Tailwind CSS: If you add tailwind-safelist.txt to your .gitignore file, you need to manually specify it as a source in your css file.

Regex Pattern Restrictions

To prevent potentially dangerous regular expressions (or in other words: prevent infinite loops while generating the safelist), the following restrictions are enforced:

  • The following metacharacters are disallowed unless escaped: *, +, ?, {, }, [, ], ^, $, .
  • Lookarounds ((?=...), (?!...), (?<=...), (?<!...)) are disallowed.
  • Backreferences (\1, \2, etc.) are disallowed.

These restrictions are in place to prevent the generator from infinite loops while generating the safelist.

Error Handling

The tool will display an error message if it encounters an invalid regex pattern in the patterns.js file. It will also exit with a non-zero exit code to indicate that an error occurred.

Contributing

Contributions are welcome! Please submit a pull request with your changes.

License

MIT