0.2.3 • Published 7 years ago

postcss-modules-dead-css v0.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

potscs-modules-dead-css npm Build Status

A PostCSS plugin to remove unused CSS from CSS Modules. Provide a list of used class names and all unused rule sets will be removed. Most useful in combination with Webpack, where static analysis can figure out the used classes for you.

Usage

var postcss = require("postcss");
var deadcss = require("postcss-modules-dead-css");

var pipeline = postcss([ deadcss({ used: ['class'] }) ]);

pipeline.process(".class { color:blue; } .otherClass { color:red; } .class:hover { color:green; }").toString();
// => '.class { color:blue; } .class:hover { color:green; }'

Options

NameDefaultDescription
used[]Array of class names to keep (don't include preceding '.')
ignore[]Array of selectors to keep (strings or RegExps)
allowIdsfalseAllow selectors which contain ids, eg #id.usedClass
allowNonClassCombinatorsfalseAllow selectors with subselectors that don't match a used class, eg .usedClass > a
allowNonClassSelectorsfalseAllow selectors that don't contain a used class at all, eg div + span

The allow* options should not be necessary with CSS Modules but may be useful when importing legacy CSS as if it were modular.

Thanks

A large part of the filtering code is lifted from uncss. Thanks!

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago