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

@cbxc/tailwind-responsive-variants

v1.0.12

Published

πŸ“¦ @cbxc/tailwind-responsive-variants

Readme

πŸ“¦ @cbxc/tailwind-responsive-variants

A zero-config Tailwind variant extractor that:

βœ“ Scans your project for calls to resClass() βœ“ Extracts responsive utilities (mob:, tab:, des:, etc.) βœ“ Generates a Tailwind safelist file (tw-generated-variants.ts) βœ“ Updates automatically via a background worker βœ“ Supports multi-line template strings βœ“ Works in large projects β€” powered by multi-threaded scanning

Perfect for React / Remix / React Router / Vite projects using custom responsive prefixes.

πŸš€ Features

Automatic variant extraction from:

resClass({ all: "flex items-center", mob: "px-4", des: "px-20", })

Outputs grouped + formatted variant lists:

export const twGeneratedVariants = { all: flex items-center gap-4 , mob: mob:px-4 , des: des:px-20 , };

Fully automated β€” no manual safelist maintenance

Parallel worker scanning for fast rebuilds

Supports nested folders & unlimited files

SSR-safe plugin for React Router + Vite + Cloudflare Workers

πŸ“₯ Installation Private npm package npm install @cbxc/tailwind-responsive-variants --save-dev

Or with Yarn:

yarn add -D @cbxc/tailwind-responsive-variants

βš™οΈ Vite Setup

Add the plugin to your Vite config:

// vite.config.ts import { defineConfig } from "vite"; import tailwindResponsiveVariants from "@cbxc/tailwind-responsive-variants/vite";

export default defineConfig({ plugins: [ tailwindResponsiveVariants(), // ...other plugins ] });

🧱 Usage: resClass()

Import the helper:

import { resClass } from "@cbxc/tailwind-responsive-variants";

Use it anywhere you'd normally use className:

πŸ—οΈ Output File

The plugin automatically creates:

app/tw-generated-variants.ts

And updates it every time a file changes.

Add this to your Tailwind config:

import { twGeneratedVariants } from "./app/tw-generated-variants";

export default { safelist: Object.values(twGeneratedVariants).flatMap((block) => block.split(/\s+/).filter(Boolean) ), };

🌐 Custom Breakpoints Supported

You can use any custom prefixes:

mob:

tab:

des:

deslg:

desxl:

Anything else you define in Tailwind

The extractor treats the prefix before the : as the variant key.

πŸ›  How it Works (Technical Summary)

A Vite plugin starts a background worker thread

Worker scans all app/**/*.{ts,tsx,js,jsx}

Parsing performed using TypeScript AST β€” fast & accurate

Each resClass({...}) call is analyzed

Variants are stored in a Map

When values change, a new fixed, deterministic, grouped output file is written

πŸ§ͺ Local Development

Inside your project:

npm link

Inside a consuming project:

npm link @cbxc/tailwind-responsive-variants

Build during development:

npm run dev

Build for release:

npm run build

πŸ”’ Private Publishing

Since this is a private npm package, your npm must be authenticated:

npm login

Then publish:

npm publish --access=restricted

🧩 Troubleshooting Cannot find module 'worker_threads'

Cloudflare SSR is trying to load the plugin β€” but the plugin is SSR-safe. Ensure your config has this (plugin adds it automatically):

ssr: { noExternal: ["@cbxc/tailwind-responsive-variants"] }

Missing variants?

Make sure your app root is correct β€” plugin uses:

/app

Correct for React Router + Remix layouts.