1. postcss-clean
PostCSS plugin to minify CSS with clean-css
postcss-clean
Package: postcss-clean
Created by: leodido
Last modified: Fri, 24 Jun 2022 09:36:10 GMT
Version: 1.2.2
License: MIT
Downloads: 61,018
Repository: https://github.com/leodido/postcss-clean

Install

npm install postcss-clean
yarn add postcss-clean

postcss-clean GitHub Workflow Status (branch) NPM Coveralls branch NPM Monthly Downloads

PostCss plugin to minify your CSS

Compression will be handled by clean-css, which according to this benchmark is one of the top (probably the best) libraries for minifying CSS.

Install

With npm do:

npm install postcss-clean --save

Example

Input

 .try {
  color: #607d8b;
  width: 32px;
}

Output

 .try{color:#607d8b;width:32px}

Input

 :host {
  display: block;
}

:host ::content {
  & > * {
    color: var(--primary-color);
  }
}

Output

 :host{display:block}:host ::content>*{color:var(--my-color)}

Note this example assumes you combined postcss-clean with other plugins (e.g. postcss-nesting).

API

clean([options])

Note that postcss-clean is an asynchronous processor. It cannot be used like this:

 var out = postcss([ clean() ]).process(css).css;
console.log(out)

Instead make sure your runner uses the async APIs:

 postcss([ clean() ]).process(css).then(function(out) {
    console.log(out.css);
});

options

It simply proxies the clean-css options. See the complete list of options here.

Usage

See the PostCSS documentation for examples for your environment.

Contributing

Pull requests are welcome.

License

MIT © Leonardo Di Donato


Analytics

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code