postcss-loader

Runs PostCSS plugins on your CSS as part of a webpack build pipeline.

Tool
npm
v8.2.1
2,843stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
64/100Good
Development Activity52
Maintenance36
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture85
Code Quality88
Innovation80
Learning Curve65

postcss-loader integrates PostCSS into webpack’s module pipeline, letting any file matched by a CSS-type rule pass through a chain of PostCSS plugins before webpack’s built-in CSS support (or css-loader) processes it further. It resolves plugins and options either from loader options or from a standalone PostCSS config file, walking up the directory tree via cosmiconfig to find package.json’s postcss key, a postcss.config.js, or a .postcssrc variant, and it forwards PostCSS’s dependency, warning, and asset messages back into the webpack compilation so watch mode and caching stay accurate.

Because it sits directly ahead of tools like autoprefixer, postcss-preset-env, and CSS Modules processing, it’s the piece that makes those plugins run at build time rather than only at authoring time — most teams that use PostCSS inside a webpack project reach it through this loader rather than calling PostCSS’s own API directly.

What You Get

  • Plugin pipeline integration — runs any PostCSS plugin chain against matched files inside a webpack use array, either as static options or an object built from a function of the loader context.
  • Automatic config discovery — searches package.json, postcss.config.{js,mjs,cjs,ts,mts,cts}, and .postcssrc variants up the directory tree via cosmiconfig, so most projects need zero loader options.
  • Source map passthrough — honors webpack’s devtool setting or an explicit sourceMap option, normalizing map source paths before and after PostCSS processing.
  • CSS-in-JS support — the execute option runs JS-authored style modules through Node’s module system first, so the postcss-js parser can process them like ordinary CSS.
  • Dependency and asset wiring — converts PostCSS’s own dependency, build-dependency, missing-dependency, context-dependency, and asset messages into webpack’s addDependency/emitFile calls automatically.

Common Use Cases

  • Running autoprefixer or postcss-preset-env inside a webpack CSS pipeline for vendor prefixing and future-syntax support.
  • Processing CSS Modules alongside PostCSS transforms using webpack’s built-in css/auto module type.
  • Compiling SugarSS or other custom PostCSS syntaxes ahead of the rest of a webpack CSS build.
  • Sharing a single postcss.config.js across multiple tools — webpack via this loader, and CI/scripts via postcss-cli.
  • Styling with CSS-in-JS by pairing the execute option with the postcss-js parser.

Under The Hood

Architecture The project is a single-purpose webpack loader split cleanly into two files: src/index.js, the loader entry point that follows webpack’s async loader contract (this.async(), this.getOptions(schema), addDependency/emitFile) and orchestrates config loading, plugin resolution, PostCSS execution, and message translation; and src/utils.js, a set of pure/stateless helpers for config discovery, plugin normalization, source-map path rewriting, and error/warning formatting. The loader detects a compatible PostCSS AST already produced by an earlier loader in the chain (meta.ast, version-checked with semver) and reuses it instead of re-parsing, and it falls back to a one-time warning (guarded by module-level state in hasExplicitDependencyOnPostCSS) when it detects a PostCSS 7 processor without an explicit postcss dependency. The design is shallow and easy to reason about — one stateful entry point, one library of pure helpers.

Tech Stack Written in modern JavaScript (ES modules), built to CommonJS via Babel (@babel/cli/@babel/preset-env) for distribution as dist/cjs.js. Configuration discovery is delegated to cosmiconfig 9, with jiti 2 used to load TypeScript/ESM config files on the fly and semver 7 used for AST-version compatibility checks. postcss and webpack are peer dependencies (webpack optional, @rspack/core also supported as an optional peer), keeping the loader’s own dependency footprint deliberately small. Tests run under Jest with ts-jest/babel-jest transforms and a custom in-repo webpack-compile harness; releases are cut with standard-version.

Code Quality The repo has nine dedicated Jest test files (loader, config-autoload, execute, implementation, postcssOptions, sourceMap, validate-options, builtInCss, cjs) using snapshot assertions against a shared test/helpers webpack-compile harness, giving good coverage of the loader’s actual runtime behavior rather than just its exports. Errors are handled explicitly throughout — config loading, plugin loading, and PostCSS processing are each wrapped in try/catch and converted into loader callback errors, with a dedicated CssSyntaxError formatter for readable output. CI (GitHub Actions nodejs.yml) runs lint and test on every push, eslint-config-webpack plus cspell enforce style and spelling, and husky/lint-staged/commitlint gate commits. There are no TypeScript source files (options are validated at runtime via a JSON Schema in src/options.json), though src/config.d.ts ships hand-written types for consumers.

API Design The public surface is deliberately small: a single postcssOptions value that can be a static object or a function of the loader context, plus sourceMap, implementation, and execute. Config-file cascading (via cosmiconfig) means most projects need no loader options at all — use: ["postcss-loader"] and a postcss.config.js is enough — while defaults for source maps (inherited from webpack’s devtool) and config lookup keep everyday configuration close to zero. Escape hatches (implementation override for downstream tooling migrating PostCSS majors, execute for CSS-in-JS, string paths for parser/stringifier/syntax) are opt-in rather than required, which keeps the common path simple without limiting advanced use.

Used by 38 apps in this directory

TypeScript
87%
Other

AFFiNE

Productivity · Project Management · Note Taking

72,238

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
67
Dependency
Built with
TypeScript87%
Updated yesterday
Python
50%
Other

Airbyte

Developer Tools · Data Engineering

21,998

Open-source ELT platform with 600+ connectors for moving data from any source to warehouses, lakes, and AI agents.

View details
95
Repo Health
80
Technical
66
Dependency
Built with
Python50%
Kotlin41%
Updated today
PHP
82%
Other

Akaunting

Invoicing Finance

10,111

Open-source online accounting for small businesses and freelancers — invoices, expenses, and reporting without monthly fees or vendor lock-in.

View details
98
Repo Health
73
Technical
63
Dependency
Built with
PHP82%
Blade13%
Updated yesterday
JavaScript
94%
MIT

Another Redis Desktop Manager

Developer Tools · Databases

34,729

Fast, stable Redis GUI with cluster, SSH, and massive key support

View details
83
Repo Health
56
Technical
67
Dependency
Built with
JavaScript94%
Updated 2 weeks ago
TypeScript
68%
Apache 2.0

Appsmith

Developer Tools · Automation · No Code Platforms

40,825

Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.

View details
93
Repo Health
79
Technical
66
Dependency
Built with
TypeScript68%
Java21%
Updated 3 days ago
PHP
63%
Other

BillaBear

Ecommerce · Invoicing Finance

758

Self-hostable subscription management and billing platform with Stripe integration, tax automation, configurable workflows, and Twig-based document generation.

View details
44
Repo Health
66
Technical
64
Dependency
Built with
PHP63%
Vue18%
Gherkin13%
Updated 3 months ago
TypeScript
53%
Other

Chaskiq

CRM · Customer Support

3,564

Self-hosted live chat, video calls, help center, and marketing automation — a full-stack Intercom alternative you run on your own infrastructure.

View details
59
Repo Health
66
Technical
66
Dependency
Built with
TypeScript53%
Ruby36%
Updated 2 months ago
JavaScript
90%
Other

CodeSandbox

Code Editors · Developer Tools

13,640

Instantly ready browser-based IDE that runs full npm dependency resolution and transpilation entirely client-side, with no server needed.

View details
69
Repo Health
76
Technical
62
Dependency
Built with
JavaScript90%
Updated 1 weeks ago
PHP
78%
Other

Craft CMS

CMS

3,605

A developer-first PHP CMS with clean-slate content modeling, auto-generated GraphQL API, and a four-tier edition system that scales from solo projects to enterprise deployments.

View details
96
Repo Health
83
Technical
62
Dependency
Built with
PHP78%
JavaScript14%
Updated yesterday

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

Search