Features
- Rule grouping
- Aggressive compression
- Selector merging
- Smart Media query handling
Installation & Usage
Installation
npm install @gafreax/csscrunch
CLI Usage
npx @gafreax/csscrunch compile input.css optimized.css
Library Usage (ESM)
import csscrunch from '@gafreax/csscrunch'
const { default: compile } = csscrunch
const cssString = '.example { color: red; font-size: 16px; }';
const parsedCSS = compile(cssString);
Library Usage (CommonJS)
const csscrunch = require('@gafreax/csscrunch')
const { default: compile } = csscrunch
const cssString = '.example { color: red; font-size: 16px; }';
const parsedCSS = compile(cssString);
Performance Comparison
CSS Crunch is built for unparalleled performance. Below is a direct benchmark comparison against clean-css, showcasing superior throughput and compression efficiency.
Toolchain Performance
CSS Crunch keeps its developer toolchain fast and modern. Type-checking runs on TypeScript 7 via tsgo (the native Go compiler), while bundling and dual CJS/ESM output are handled by tsdown (built on Rolldown, in Rust). Measured on this repository:
Type-check --noEmit
~3.4× faster
~0.34 s with tsc 6.0.3 → ~0.10 s with tsgo
Build & bundling
tsdown
Rolldown (Rust) — dual CJS/ESM output with .d.ts
tsgo reports the same type errors as tsc. TypeScript 7 is still in preview, so it is used for type-checking only (which emits nothing); the published declaration files are generated by the stable TypeScript compiler, with the native tsgo path kept opt-in until TS 7 is stable.