Use giakki/uncss as a postcss plugin
Last updated 3 years ago by ryanzim .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install postcss-uncss 
SYNC missed versions from official npm registry.


npm npm

Use uncss as a PostCSS plugin.


UnCSS is a tool that removes unused CSS from your stylesheets. It works across multiple files and supports Javascript-injected CSS.



  <p class="red">Hello World!</p>

css before:

.red {
  color: red;
.blue {
  color: blue;

css after:

.red {
  color: red;


The HTML files are loaded by jsdom and JavaScript is executed. UnCSS filters out selectors that are not found in the HTML files.

See the UnCSS docs for more information.


postcss-uncss specifies UnCSS as a peerDependency, so you will have to install UnCSS as well.

npm install postcss-uncss uncss

postcss-uncss' MAJOR & MINOR version numbers correspond to UnCSS' version numbers; however, the PATCH version number may differ.


postcss([ require('postcss-uncss') ])

See PostCSS docs for examples for your environment.


  • html (Array): provide a list of html files to parse for selectors and elements. Usage of globs is allowed.

  • ignore (Array): provide a list of selectors that should not be removed by UnCSS. For example, styles added by user interaction with the page (hover, click), since those are not detectable by UnCSS yet. Both literal names and regex patterns are recognized. Otherwise, you can add a comment before specific selectors in your css:

    /* uncss:ignore */
    .selector1 {
        /* this rule will be ignored */
    .selector2 {
        /* this will NOT be ignored */

Example Configuration

  html: ['index.html', 'about.html', 'team/*.html'],
  ignore: ['.fade']

Current Tags

  • 0.17.0                                ...           latest (a year ago)

5 Versions

  • 0.17.0                                ...           a year ago
  • 0.16.1                                ...           3 years ago
  • 0.15.0                                ...           3 years ago
  • 0.14.0                                ...           4 years ago
  • 0.0.1                                ...           4 years ago

Copyright 2014 - 2017 © |