PostCSS plugin wrapping lightningcss for CSS compilation, vendor prefixing (replacing autoprefixer), minification, CSS Modules, and more. Current stable version is 1.1.0, released in early 2025, with gradual release cadence. Key differentiators: uses lightningcss which is written in Rust for speed, can replace multiple PostCSS plugins (autoprefixer, cssnano), supports modern CSS drafts like nesting, and ships TypeScript types. Peer dependency on PostCSS 8, requires Node.js >=20.19.
npm install postcss-lightningcssNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of postcss-lightningcss with PostCSS: import, create plugin with options, process CSS, and get minified output.
Use import syntax or dynamic import(). If using CommonJS, stick to v1.0.x or transpile with bundler.
Upgrade Node.js to version 20.19.0 or newer (or 22.12+, 24+).
Always invoke with options: postcssLightningcss({...})Provide cssModulesJSON callback to capture the mapping, e.g., write to JSON file.
Remove autoprefixer from PostCSS config and rely on postcss-lightningcss's browsers option.
Change to 'import postcssLightningcss from "postcss-lightningcss";' in an ES module, or use dynamic import: 'const postcssLightningcss = (await import("postcss-lightningcss")).default;'Use postcss([postcssLightningcss({...})]) instead of postcss([postcssLightningcss]).Upgrade Node.js to >=20.19.0 and ensure your project is set up for ES modules (e.g., add "type": "module" to package.json or use .mjs files).