Registry / testing / clean-css-lu

clean-css-lu

JSON →
library3.4.7jsnpmunverified

A fast and efficient Node.js library for minifying CSS files. Version 3.4.7 is the latest stable release of the 3.x series. It provides both a CLI and a programmable API. Key differentiators include high performance, support for advanced optimizations like semantic merging and shorthand compacting, source map generation, and compatibility modes for IE7/IE8.

npm install clean-css-lu
INSTALL
IMPORT
SIG · CLEAN-CSS-LU
C
clean-css-lu
testingjavascriptv3.4.7
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.

CleanCSS
var CleanCSS = require('clean-css');
import CleanCSS from 'clean-css';
clean-css v3 is CommonJS-only; ESM import is not supported.
CleanCSS.minify
new CleanCSS().minify(source).styles;
CleanCSS.minify(source);
minify is an instance method, not a static method.
CLI
cleancss -o output.css input.css
clean-css -o output.css input.css
The CLI command is `cleancss`, not `clean-css`.

Minify a simple CSS string using the clean-css API and print the result.

var CleanCSS = require('clean-css'); var source = 'a{font-weight:bold;}'; var minified = new CleanCSS().minify(source).styles; console.log(minified); // 'a{font-weight:700}'
Debug
Known issues
gotchaminify() returns an object with .styles, not just the string.
fix
Access result.styles after calling new CleanCSS().minify(source).
affects: >=3.0.0
gotchaAPI is callback-based in v4 but synchronous in v3. Upgrading to v4 requires changing code that relies on sync output.
fix
If upgrading to v4, use the promise-based or callback-based minify method.
affects: >=3.0.0 <4.0.0
deprecatedNode.js 0.10 and io.js 3.0 are no longer supported by the ecosystem.
fix
Use Node.js >=4.0.0 for security updates.
affects: >=3.0.0 <3.4.7
gotchaThe CLI does not support glob patterns out of the box.
fix
Use shell expansion or pass multiple files explicitly (e.g., cleancss file1.css file2.css).
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'clean-css'
clean-css is not installed or is installed globally but required locally.
fix
Run 'npm install clean-css' in your project directory.
TypeError: CleanCSS is not a constructor
Using import or require incorrectly (e.g., CleanCSS = require('clean-css').CleanCSS).
fix
Use 'var CleanCSS = require('clean-css');' and then 'new CleanCSS()'.
clean-css: command not found
clean-css CLI is not installed globally or not in PATH.
fix
Install globally: 'npm install -g clean-css' or use npx: 'npx clean-css --help'.
TypeError: source is not a string
Passing non-string input to minify().
fix
Ensure the argument to minify() is a CSS string.
Upgrade
Version history
3.4.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
clean-css-lu — npm install clean-css-lu · libregistry