Dead simple CSS purge tool.
npm install css-chosen --save-dev
The project was inspired by uncss, we both tend to use dom's querySelector
method. But we use css-select to select css rules, which allows us to remove the dependency of jsdom, so it will be smaller and faster.
The process by which css-chosen removes the unused rules is as follows:
- The HTML files are loaded by htmlparser2 to get doms.
- All the stylesheets are parsed by a simple build-in css parser.
CSSselect.selectOne
filters out selectors that are not found in the HTML files.- The remaining rules are converted back to CSS.
windicss uses css-chosen to purge base styles added by third-party plugins.