CodeVetter · Repo Unpack · Feature catalog
postcss/postcss
The user-facing surface is a JavaScript API for transforming and inspecting CSS. Callers can use plugin processing, direct parsing, programmatic AST construction, custom syntaxes, diagnostics, source maps, and JSON hydration. Ecosystem tools supply features such as prefixing and linting, while external runners supply CLI and build-tool integration. Core features preserve source and formatting information to support those integrations.
- Callers can configure a reusable Processor with postcss(plugins), append plugins through use(plugin), and process multiple CSS inputs with per-call options.
- LazyResult supports synchronous css/root/messages access and promise-style then, catch, and finally; synchronous processing throws when a plugin returns a promise.
- The public API exposes factories for comments, at-rules, declarations, rules, roots, and documents, plus cloning, replacement, sibling insertion, and removal operations.
- Container offers mutation-aware walk plus type-specific walkAtRules, walkComments, walkDecls, and walkRules; applicable filters accept exact strings or regular expressions, and callbacks can stop traversal with false.
- ProcessOptions accepts parser, stringifier, or combined syntax replacements, along with document, from, to, map, and unsafeMap; custom parsers can return Root or Document.
- Source-map options include inline/external output, annotation strings or callbacks, source-name overrides, absolute paths, previous maps, and optional source content.
- Node.error creates source-positioned CssSyntaxError objects, Node.warn attaches nodes to result warnings, and Result.warnings filters the shared message channel by type.
- Node.toJSON and postcss.fromJSON provide AST serialization/hydration; list.comma, list.space, and list.split separate values while respecting quotes, escapes, comments, and parentheses.