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

eva-css-purge

v2.0.7

Published

Intelligent CSS purging tool for EVA CSS projects

Readme

eva-css-purge

Intelligent CSS purging tool for EVA CSS projects

Removes unused CSS classes, IDs, and optimizes your stylesheets while keeping what matters.

🎯 Features

  • Smart Analysis: Scans HTML, JS, Vue, JSX, TSX files
  • CSS Variables: Preserves all CSS variables (critical for EVA CSS)
  • Element Selectors: Keeps all HTML element styles
  • Dynamic Classes: Detects classes used in JavaScript
  • Compression: Minifies output CSS
  • Safelist: Protect specific classes from removal
  • CLI & Programmatic: Use via command line or in your build process

📦 Installation

npm install eva-css-purge
# or
pnpm add eva-css-purge
# or
yarn add eva-css-purge

🚀 Usage

CLI Usage

# Basic usage
eva-purge --css dist/style.css --content "src/**/*.html"

# Multiple content patterns
eva-purge --css dist/style.css --content "src/**/*.{html,js,vue}"

# Custom output
eva-purge --css dist/style.css --content "src/**/*" --output dist/style-purged.css

# With safelist (classes to always keep)
eva-purge --css dist/style.css --safelist "theme-,current-,all-grads"

# Using config file
eva-purge --config eva.config.js

Configuration File

Create eva.config.js:

module.exports = {
  purge: {
    // Content files to scan
    content: [
      'src/**/*.html',
      'src/**/*.js',
      'src/**/*.vue',
      'src/**/*.jsx',
      'src/**/*.tsx'
    ],

    // CSS file to purge
    css: 'dist/style.css',

    // Output file
    output: 'dist/style-purged.css',

    // Classes to keep (optional)
    safelist: {
      standard: ['current-theme', 'all-grads', 'toggle-theme'],
      deep: [/^theme-/],        // Regex patterns
      greedy: [/^brand-/, /^accent-/]
    }
  }
};

Then run:

eva-purge --config eva.config.js

Programmatic Usage

const CSSPurger = require('eva-css-purge');

const config = {
  content: ['src/**/*.{html,js}'],
  css: 'dist/style.css',
  output: 'dist/style-purged.css'
};

const purger = new CSSPurger(config);
await purger.purge();

Integration with Build Tools

With npm scripts:

{
  "scripts": {
    "build:css": "sass src/styles.scss dist/style.css",
    "purge:css": "eva-purge --css dist/style.css --content 'src/**/*.html'",
    "build": "npm run build:css && npm run purge:css"
  }
}

With Vite:

// vite.config.js
import { defineConfig } from 'vite';
import { exec } from 'child_process';

export default defineConfig({
  plugins: [
    {
      name: 'eva-purge',
      closeBundle() {
        exec('eva-purge --css dist/assets/style.css --content "dist/**/*.html"');
      }
    }
  ]
});

📋 What Gets Kept

eva-css-purge intelligently keeps:

CSS Variables - All :root variables (essential for EVA CSS) ✅ HTML Elements - body, h1, p, button, etc. ✅ Used Classes - Classes found in HTML/JS files ✅ Used IDs - IDs found in HTML/JS files ✅ Media Queries - All responsive breakpoints ✅ Theme Classes - .current-theme, .all-grads, etc. ✅ Dynamic Classes - Classes from classList.add(), querySelector()

❌ What Gets Removed

Unused Classes - Classes not found in any content files ❌ Unused IDs - IDs not referenced anywhere ❌ Comments - CSS comments (optional) ❌ Whitespace - Extra spaces and newlines

🎨 Perfect for EVA CSS

eva-css-purge is specifically designed for EVA CSS projects:

  • Preserves all CSS variable definitions in :root
  • Keeps utility classes like w-64, p-16, fs-32
  • Maintains color classes like _bg-brand, _c-accent
  • Protects theme classes like .theme-*
  • Preserves gradient system classes .all-grads

📊 Example Results

Original CSS:  120 KB
Purged CSS:     45 KB
Space saved:   62.5%

Typical savings: 40-70% depending on your project.

🧪 Testing

Run the included test suite:

cd packages/eva-purge
pnpm test

📄 License

MIT © Michaël Tati

👨‍💻 Author

Michaël Tati

🔗 Related Packages