@ui-entropy/scanner-core
v0.3.0
Published
CSS waste detection engine - finds unused classes and IDs in your codebase
Maintainers
Readme
@ui-entropy/scanner-core
Core CSS waste detection engine for programmatic use. Powers the UI Entropy CLI and dashboard.
This package provides the core analysis engine for UI Entropy Scanner. It's designed for programmatic use in Node.js applications, build tools, and custom integrations.
For command-line usage, see @ui-entropy/cli which includes smart initialization and colored output.
🚀 Features
- Smart CSS Parsing - Supports Bootstrap, Tailwind, custom CSS with PostCSS
- Multi-Framework Support - Works with React, Vue, Angular, HTML, and more
- Accurate Detection - Handles variants (
hover:,dark:), pseudo-classes, complex selectors - Fast Scanning - Optimized file crawling with glob patterns
- Configurable -
.gitignoreintegration, custom ignore patterns - TypeScript Native - Full type definitions included
📦 Installation
npm install @ui-entropy/scanner-coreFor CLI usage, install the main package instead:
npm install -g @ui-entropy/cliThe CLI includes smart project initialization:
npx @ui-entropy/cli init # Auto-detects your framework
npx @ui-entropy/cli scan # Scan with generated config🔧 Quick Start
import { scan } from '@ui-entropy/scanner-core';
// Scan your entire project
const result = scan({
baseDir: '/path/to/your/project',
cssPattern: '**/*.css',
sourcePattern: '**/*.{html,jsx,tsx,vue}',
format: 'text'
});
console.log(result.output);📊 Example Output
🔍 UI Entropy Analysis Report
═══════════════════════════════════════════════
📊 Summary
Total CSS Size: 45.2 KB
Total Rules: 1,247
Files Scanned: 89
🎯 Selectors
Total Selectors: 1,247
Used Selectors: 329 (26%)
Unused Selectors: 918
💰 CSS Waste Analysis
Waste Percentage: 73.6%
Estimated Wasted Bytes: 33.3 KB
💡 CRITICAL WASTE: Significant cleanup needed.🛠️ API Reference
scan(options)
Main scanning function.
Options:
baseDir- Project root directory (required)cssPattern- Glob pattern for CSS files (default:**/*.css)sourcePattern- Glob pattern for source filesformat- Output format:'text'|'json'|'summary'ignorePatterns- Additional patterns to ignore
Returns: ScanResult with analysis data and formatted output
extractSelectors(cssContent)
Extract all CSS selectors from a stylesheet.
extractUsageFromMultiple(files, baseDir)
Find all class/ID usage across source files.
analyzeWaste(selectors, usage)
Calculate waste metrics and identify unused selectors.
Related Packages
- ui-entropy - CLI tool for terminal usage
- UI Entropy Dashboard (coming soon) - Team analytics and historical tracking
📚 Documentation
📝 License
Proprietary - See LICENSE file.
Use subject to UI Entropy subscription terms.
💬 Support
Built with TypeScript, PostCSS, and modern tooling for professional development teams.
