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

postcss-reduce-idents

v7.0.0

Published

Reduce custom identifiers with PostCSS.

Downloads

3,030,743

Readme

postcss-reduce-idents

Reduce custom identifiers with PostCSS.

Install

With npm do:

npm install postcss-reduce-idents --save

Example

Input

This module will rename custom identifiers in your CSS files; it does so by converting each name to a index, which is then encoded into a legal identifier. A legal custom identifier in CSS is case sensitive and must start with a letter, but can contain digits, hyphens and underscores. There are over 3,000 possible two character identifiers, and 51 possible single character identifiers that will be generated.

@keyframes whiteToBlack {
    0% {
        color: #fff
    }
    to {
        color: #000
    }
}

.one {
    animation-name: whiteToBlack
}

Output

@keyframes a {
    0% {
        color: #fff
    }
    to {
        color: #000
    }
}

.one {
    animation-name: a
}

Note that this module does not handle identifiers that are not linked together. The following example will not be transformed in any way:

@keyframes fadeOut {
    0% { opacity: 1 }
    to { opacity: 0 }
}

.fadeIn {
    animation-name: fadeIn;
}

It works for @keyframes, @counter-style, custom counter values and grid area definitions. See the documentation for more information, or the tests for more examples.

Usage

See the PostCSS documentation for examples for your environment.

API

reduceIdents([options])

options

counter

Type: boolean
Default: true

Pass false to disable reducing content, counter-reset and counter-increment declarations.

keyframes

Type: boolean
Default: true

Pass false to disable reducing keyframes rules and animation declarations.

counterStyle

Type: boolean
Default: true

Pass false to disable reducing counter-style rules and list-style and system declarations.

gridTemplate

Type: boolean
Default: true

Pass false to disable reducing grid-template, grid-area, grid-column, grid-row and grid-template-areas declarations.

encoder

Type: function
Default: lib/encode.js

Pass a custom function to encode the identifier with (e.g.: as a way of prefixing them automatically).

It receives two parameters:

  • A String with the node value.
  • A Number identifying the index of the occurrence.

Contributors

See CONTRIBUTORS.md.

License

MIT © Ben Briggs