cssnano

A modular CSS minifier built on the PostCSS ecosystem, composing dozens of swappable optimization plugins into safe, lite, and advanced presets.

Library
npm
v9.9.0
4,982 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
90 /100 Excellent
Development Activity 100
Maintenance 96
Community 64
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
89 /100 Excellent
Architecture 85
Code Quality 88
Innovation 82
Learning Curve 100

cssnano is a modular CSS minifier built on top of the PostCSS ecosystem. Rather than a single monolithic compressor, it composes dozens of independent PostCSS plugins — each handling one optimization, from merging duplicate rules to normalizing color and gradient syntax — into configurable presets.

Three built-in presets (default, lite, advanced) trade off safety for aggressiveness, and cssnano can also load a fully custom plugin list or config file, making it equally suited to drop-in build-tool integration and hand-tuned minification pipelines.

What You Get

  • Three ready-made presets — default (safe optimizations), lite (whitespace-focused, minimal risk), and advanced (aggressive transforms like identifier mangling and z-index renumbering) — for different risk tolerances
  • Dozens of independently versioned PostCSS plugins (postcss-merge-rules, postcss-colormin, postcss-convert-values, postcss-svgo, and more) that can be composed individually
  • Config file discovery (cssnano.config.js, .cssnanorc.json) so projects can override preset choice or plugin options without touching build scripts
  • Browserslist-aware transforms that adjust output (autoprefixer handling, vendor-prefix decisions) based on the browsers a project targets
  • A hosted documentation site with an interactive playground for testing optimizations against real CSS

Common Use Cases

  • Minifying production CSS bundles inside webpack/PostCSS/Vite build pipelines via postcss-loader or a postcss.config.js entry
  • Framework integrations that ship cssnano as the default production CSS minifier (Next.js-style and other bundler toolchains)
  • CLI/CI minification steps that pipe a build’s compiled CSS through cssnano before deployment
  • Custom minification pipelines that hand-pick specific optimization plugins instead of a full preset, for teams needing fine control over allowed transforms

Under The Hood

Architecture

cssnano’s entry point (packages/cssnano/src/index.js) is a thin PostCSS plugin factory that resolves a “preset” — a string alias, a factory function, an already-invoked { plugins: [] } object, or a config file discovered from .cssnanorc.json/cssnano.config.js — into a flat array of [pluginCreator, options] tuples, then hands them to postcss(). Every actual optimization lives in its own workspace package under packages/; the advanced preset is built by layering extra plugins (postcss-discard-unused, postcss-merge-idents, postcss-zindex, css-declaration-sorter) on top of the default preset rather than duplicating its plugin list. Individual optimization packages, such as postcss-merge-rules, further split their own logic into a src/lib/ directory (compatibility checks, rule rewriting, property-relation tables) so each transform’s edge cases stay isolated and independently testable. Because the entire system funnels through resolvePreset/resolveConfig, that indirection is the one place where a change ripples through every preset and every downstream framework integration.

Tech Stack

The project is a pnpm workspace monorepo (pnpm-workspace.yaml with a shared dependency “catalog” for versions like postcss and browserslist) targeting modern Node (^22.22.3 || ^24.15.0 || >=26.0) as native ESM ("type": "module"). Rather than hand-written .ts files, packages are plain JavaScript with JSDoc type annotations checked by tsc -b in emitDeclarationOnly mode across project references for every workspace package, giving full TypeScript strictness without a compile step. Linting and formatting run through oxlint/oxfmt (Rust-based tooling) instead of ESLint/Prettier. Core optimizations build on postcss (peer dependency ^8.5.28), browserslist, autoprefixer, postcss-calc, and postcss-svgo for SVG-in-CSS minification.

Code Quality

Tests run on Node’s built-in test runner (node --test) rather than a third-party framework, with per-package test/ directories that include extensive named regression tests for previously reported bugs (issue26.js, issue927.js, issue1594.js) alongside a dedicated config_loading suite that exercises real temp-directory config discovery. A separate mutation-testing harness (util/mutation-testing/) validates that the test suite actually catches injected faults in select optimization plugins. GitHub Actions run test.yml, performance.yml, and publish.yml workflows, coverage is tracked via Codecov, and Dependabot keeps dependencies current — a mature quality bar for a project this size.

API Design The public surface is a single PostCSS plugin: postcss([cssnano]).process(css), with zero required configuration — the default preset applies automatically. Choosing a different risk profile is a one-line change ({ preset: 'lite' } or { preset: 'advanced' }), and teams needing full control can instead pass an explicit plugins array or drop a cssnano.config.js file that the loader discovers on its own. Documentation lives on a dedicated Astro-based site with a live playground rather than being crammed into the README, keeping the package itself lightweight (a single direct dependency: cssnano-preset-default).

Used by 25 apps in this directory

JavaScript
42%
Other

LimeSurvey

Forms Surveys

3,778

The world's most flexible open-source survey platform with 900+ templates, conditional logic, 80+ languages, and full GDPR compliance for any scale.

View details
86
Repo Health
62
Technical
62
Dependency
Built with
JavaScript 42%
PHP 36%
CSS 12%
Updated 6 days ago
Clojure
71%
AGPL 3.0

Logseq

Knowledge Management · Note Taking

45,349

A privacy-first, open-source knowledge graph platform combining Markdown, Org-mode, bidirectional linking, and local-first storage for building your second brain.

View details
92
Repo Health
82
Technical
65
Dependency
Built with
Clojure 71%
OCaml 12%
Updated 1 weeks ago
Python
62%
Apache 2.0

marimo

Data Engineering · Developer Tools

23,309

A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.

View details
90
Repo Health
91
Technical
65
Dependency
Built with
Python 62%
TypeScript 37%
Updated 6 days ago
TypeScript
95%
MIT

melty

AI Code Assistants · Code Editors · Developer Tools

5,462

The AI code editor where every chat message is a git commit you can revert, branch, or squash

View details
35
Repo Health
75
Technical
67
Dependency
Built with
TypeScript 95%
Updated 1 years ago
TypeScript
98%
Other

Novu

Developer Tools

40,195

Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.

View details
93
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 98%
Updated 6 days ago
TypeScript
54%
Other

OpenReplay

Analytics

13,042

Self-hosted session replay and product analytics suite that lets you see exactly what users do on your web app — without sending data to third parties.

View details
91
Repo Health
77
Technical
66
Dependency
Built with
TypeScript 54%
Go 13%
Updated 1 weeks ago
TypeScript
51%
ZLIB

Portainer

Devops

38,707

A lightweight, open-source web UI that puts Docker, Kubernetes, and Podman management within reach of any team—no CLI expertise required.

View details
93
Repo Health
79
Technical
65
Dependency
Built with
TypeScript 51%
Go 38%
Updated 1 weeks ago
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

40,397

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python 55%
TypeScript 36%
Updated 6 days ago
TypeScript
97%
Other

Rocket.Chat

Team Chat

46,304

The secure, self-hosted team communications platform for organizations that cannot compromise on data sovereignty.

View details
96
Repo Health
79
Technical
63
Dependency
Built with
TypeScript 97%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers