Registry / devops / postcss-csso

postcss-csso

JSON →
library6.0.1jsnpmunverified

PostCSS plugin to minify CSS using CSSO (v6.0.1). It converts PostCSS AST to CSSO's AST, optimizes it, then converts back, preserving original node shapes. Releases follow semver with occasional minor bumps. Differentiators: preserves PostCSS node structure, generates correct source maps, and offers performance comparable to standalone CSSO. Requires PostCSS v8+ as a peer dependency. Useful in build pipelines via PostCSS configuration.

npm install postcss-csso
INSTALL
IMPORT
SIG · POSTCSS-CSSO
P
postcss-csso
devopsjavascriptv6.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import csso from 'postcss-csso'
const csso = require('postcss-csso').default
ESM default import is recommended; CommonJS require works directly as the package exports a function as default.
csso (CommonJS)
const csso = require('postcss-csso')
const { csso } = require('postcss-csso')
CommonJS require returns the plugin function directly, not an object.
Options
csso({ restructure: false })
csso({ compress: { restructure: false } })
Options are passed directly to CSSO's compress method; no extra wrapper.

Shows basic usage of postcss-csso with options, processing CSS input and logging minified output.

import postcss from 'postcss'; import csso from 'postcss-csso'; postcss([ csso({ restructure: false }) ]) .process('.a { color: #FF0000; } .b { color: rgba(255, 0, 0, 1) }') .then((result) => { console.log(result.css); // .a{color:red}.b{color:red} });
Debug
Known issues
breakingVersion 5.0.0 dropped support for Node.js < 12 and PostCSS < 8.
fix
Upgrade to Node.js >=12 and PostCSS >=8.
affects: >=5.0.0
deprecatedThe 'restructure' option is still supported but its default may change in future majors.
fix
Explicitly set { restructure: true/false } to ensure consistent behavior.
affects: >=6.0.0
gotchaCSSO's 'forceMediaMerge' option is not exported and not supported.
fix
Use 'csso({ forceMediaMerge: true })' - note: this option may be ignored or cause errors.
affects: all
Errors
Common errors & fixes
TypeError: csso is not a function
Using destructured import like 'import { csso } from 'postcss-csso'' when the module exports a default.
fix
Use 'import csso from 'postcss-csso'' or 'const csso = require('postcss-csso')'
Error: PostCSS plugin postcss-csso requires PostCSS 8.
Installed version of PostCSS is <8.
fix
Upgrade PostCSS to version 8 or later.
Upgrade
Version history
6.0.1latest on npm
Audit
Dependencies
postcssrequiredPeer dependency; required by plugin to process CSS
Agent activity
8 hits · last 30 days
node
8
Resources
postcss-csso — npm install postcss-csso · libregistry