PostCSS: modular CSS transformation with JavaScript

PostCSS (September 2013) by Andrey Sitnik: JavaScript tool to transform CSS with plugins. Autoprefixer, CSS Modules, CSS Nano, new CSS syntaxes. Modular architecture alternative to monolithic preprocessors.

Open SourceWeb PostCSSAndrey SitnikAutoprefixerCSSOpen SourceWebFrontend

A different philosophy

While Sass and Less are monolithic preprocessors that add extended syntax to CSS, PostCSS proposes a different approach: a JavaScript parser that produces a CSS AST, on which modular plugins can apply arbitrary transformations. CSS remains standard CSS; plugins add or remove features as needed.

The release

PostCSS 1.0 is published in September 2013 by Andrey Sitnik, Russian developer at Evil Martians. MIT licence. Written in JavaScript (later TypeScript).

const postcss = require('postcss');
const autoprefixer = require('autoprefixer');
postcss([autoprefixer]).process(css).then(r => r.css);

Main plugins

  • Autoprefixer — automatically adds vendor prefixes (-webkit-, -moz-) based on browserslist and caniuse.com data
  • cssnano — CSS minifier
  • PostCSS Preset Env — allows modern CSS syntax with polyfills
  • PostCSS Nested — Sass-like nesting
  • PostCSS Mixins, Variables, Functions — optional preprocessor-like features
  • CSS Modules — local scope of classes (name hash)
  • Tailwind CSS — PostCSS plugin in original implementation
  • PurgeCSS — removes unused CSS

Integration

PostCSS is integrated by default in:

  • Vite (via postcss.config.js)
  • Next.js
  • Create React App
  • Parcel
  • Webpack (via postcss-loader)
  • Nuxt.js

Autoprefixer: the killer feature

Autoprefixer is the main reason for mass adoption: it handles vendor prefixes without the developer having to remember which browsers require them. It reads .browserslistrc (e.g. "last 2 versions, >1%") and generates only the necessary prefixes. It has made obsolete tools like Compass @include mixins for gradients.

In the Italian context

PostCSS is invisible but ubiquitous: every modern Italian frontend project (React, Vue, Svelte, Astro) has Autoprefixer and perhaps cssnano in the pipeline via PostCSS. Tailwind CSS in version 3 required PostCSS; version 4 (2024-2025) has its own Rust engine.


References: PostCSS 1.0 (September 2013). Andrey Sitnik, Evil Martians. MIT licence. Autoprefixer, cssnano, CSS Modules, Tailwind (v1-v3) plugins. Integrated in Vite, Next.js, Parcel.

Need support? Under attack? Service Status
Need support? Under attack? Service Status