JSPM

  • Created
  • Published
  • Downloads 795450
  • Score
    100M100P100Q213973F
  • License MIT

Reduce custom identifiers with PostCSS.

Package Exports

  • postcss-reduce-idents

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-reduce-idents) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

postcss-reduce-idents Build Status NPM version Dependency Status

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 and custom counter values. See the documentation for more information, or the tests for more examples.

Usage

See the PostCSS documentation for examples for your environment.

Contributing

Pull requests are welcome. If you add functionality, then please add unit tests to cover it.

License

MIT © Ben Briggs