postcss-reduce-idents

WebJar for postcss-reduce-idents

License

License

MIT
Categories

Categories

IDE Development Tools
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

postcss-reduce-idents
Last Version

Last Version

2.4.0
Release Date

Release Date

Type

Type

jar
Description

Description

postcss-reduce-idents
WebJar for postcss-reduce-idents
Project URL

Project URL

http://webjars.org

Download postcss-reduce-idents

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/postcss-reduce-idents/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>postcss-reduce-idents</artifactId>
    <version>2.4.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/postcss-reduce-idents/
implementation 'org.webjars.npm:postcss-reduce-idents:2.4.0'
// https://jarcasting.com/artifacts/org.webjars.npm/postcss-reduce-idents/
implementation ("org.webjars.npm:postcss-reduce-idents:2.4.0")
'org.webjars.npm:postcss-reduce-idents:jar:2.4.0'
<dependency org="org.webjars.npm" name="postcss-reduce-idents" rev="2.4.0">
  <artifact name="postcss-reduce-idents" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='postcss-reduce-idents', version='2.4.0')
)
libraryDependencies += "org.webjars.npm" % "postcss-reduce-idents" % "2.4.0"
[org.webjars.npm/postcss-reduce-idents "2.4.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : postcss jar [5.0.4,6)
org.webjars.npm : postcss-value-parser jar [3.0.2,4)

Project Modules

There are no modules declared in this project.

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, 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 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

Thanks goes to these wonderful people (emoji key):


Ben Briggs

๐Ÿ’ป ๐Ÿ“– ๐Ÿ‘€ โš ๏ธ

Bogdan Chadkin

โš ๏ธ ๐Ÿ’ป

Guillermo Rauch

๐Ÿ’ป ๐Ÿ“– โš ๏ธ

Sylvain Pollet-Villard

๐Ÿ’ป ๐Ÿ“– โš ๏ธ

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT ยฉ Ben Briggs

Versions

Version
2.4.0