npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

usedcss

v1.0.7

Published

Extract only styles presented in your html files.

Downloads

116

Readme

usedcss

PostCSS plugin which helps you extract only used styles. Unlike uncss and others does not render your pages to find used classes, but instead parse it statically, which can be beneficial in some cases. Also support simple Angular's ng-class parsing. And also, due to awesomeness of PostCSS, it works with LESS and SCSS via PostCSS syntaxes.

<!--- HTML file -->
<div class="test"></div>
/* Input */
.test { color: #000; }
.test2 { color: #fff; }
/* Output */
.test { color: #000; }

Installation

npm i usedcss --save

Options

html

Type: array of globs At least html or js option is required

HTML files to check css selector usage against them.

js

Type: array of globs At least html or js option is required

JS files to check css selector usage against them.

ignore

Type: array of strings

Saves ignored selectors even if they are not presented in DOM.

ignoreRegexp

Type: array of regexps

Use it to save selectors based on regexp.

ngclass

Type: boolean

Default: false

Parse or not to parse ng-class statements.

ignoreNesting

Type: boolean

Default: false

Ignore nesting so .class1 .class2 will be saved even if there is element with class2, but it's not nested with class1. Useful if you use templates.

templateMode

Type: boolean

Default: false

Useful if you run usedcss against nested templates. It split selectors so if you have an element with class class1 in one file and an element with class class2 in another one, it will save rule with .class1 .class2 selector.

templateCache

Type: boolean

Default: false

Check also for html presented in Angular's $templateCache. If you want to use this option, js option is required.

Usage

Check out PostCSS documentation on how to use PostCSS plugins.