postcss-convert-values
Convert values with PostCSS (e.g. ms -> s)
Last updated a month ago by GitHub Actions .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install postcss-convert-values 
SYNC missed versions from official npm registry.

postcss-convert-values

Convert values with PostCSS (e.g. ms -> s)

Install

With npm do:

npm install postcss-convert-values --save

Example

This plugin reduces CSS size by converting values to use different units where possible; for example, 500ms can be represented as .5s. You can read more about these units in this article.

Input

h1 {
    font-size: 16px;
    width: 0em
}

Output

h1 {
    font-size: 1pc;
    width: 0
}

Note that this plugin only covers conversions for duration, frequency, angle and absolute length values. For color conversions, use [postcss-colormin][colormin].

API

convertValues([options])

options

length

Type: boolean Default: true

Pass false to disable conversion among px, pt, pc & in. cm & mm always convert, and q is converted from but never to, because it has lower browser support than cm and mm.

time

Type: boolean Default: true

Pass false to disable conversion from ms to s & vice versa.

angle

Type: boolean Default: true

Pass false to disable conversion from deg to turn & vice versa.

frequency

Type: boolean Default: true

Pass false to disable conversion from Hz to kHz & vice versa.

precision

Type: false|number Default: false

Specify any numeric value here to round dimensions (such as px, em or s values) to that many decimal places; for example, using {precision: 2} will round 6.66667px to 6.67px, and {precision: 0} will round it to 7px. Passing false (the default) will leave these values as is.

It is recommended for most use cases to set this option to 2.

transformCustomProperties

Type: boolean Default: false

Pass true to also convert values in custom properties (--*). They are left as written by default, because their value is only interpreted where it is substituted.

Usage

See the PostCSS documentation for examples for your environment.

Contributors

See CONTRIBUTORS.md.

License

MIT © Ben Briggs

Current Tags

  • 9.1.0                                ...           latest (a month ago)
  • 5.0.0-rc.2                                ...           next (6 years ago)
  • 4.0.0-nightly.2020.2.6                                ...           nightly (6 years ago)

100 Versions

  • 9.1.0                                ...           a month ago
  • 9.0.9                                ...           2 months ago
  • 9.0.8                                ...           2 months ago
  • 9.0.7                                ...           2 months ago
  • 9.0.6                                ...           2 months ago
  • 9.0.5                                ...           2 months ago
  • 9.0.4                                ...           2 months ago
  • 9.0.3                                ...           2 months ago
  • 9.0.2                                ...           3 months ago
  • 9.0.1                                ...           3 months ago
  • 9.0.0                                ...           3 months ago
  • 8.0.4                                ...           3 months ago
  • 8.0.3                                ...           4 months ago
  • 8.0.2                                ...           4 months ago
  • 8.0.1                                ...           6 months ago
  • 8.0.0                                ...           7 months ago
  • 7.0.12                                ...           7 months ago
  • 7.0.11                                ...           7 months ago
  • 7.0.10                                ...           7 months ago
  • 7.0.9                                ...           9 months ago
  • 7.0.8                                ...           a year ago
  • 7.0.7                                ...           a year ago
  • 7.0.6                                ...           a year ago
  • 7.0.5                                ...           2 years ago
  • 7.0.4                                ...           2 years ago
  • 7.0.3                                ...           2 years ago
  • 7.0.2                                ...           2 years ago
  • 7.0.1                                ...           2 years ago
  • 7.0.0                                ...           3 years ago
  • 6.1.0                                ...           3 years ago
  • 6.0.4                                ...           3 years ago
  • 6.0.3                                ...           3 years ago
  • 6.0.2                                ...           3 years ago
  • 6.0.1                                ...           3 years ago
  • 6.0.0                                ...           4 years ago
  • 5.1.3                                ...           4 years ago
  • 5.1.2                                ...           4 years ago
  • 5.1.1                                ...           5 years ago
  • 5.1.0                                ...           5 years ago
  • 5.0.4                                ...           5 years ago
  • 5.0.3                                ...           5 years ago
  • 5.0.2                                ...           5 years ago
  • 5.0.1                                ...           6 years ago
  • 5.0.0                                ...           6 years ago
  • 5.0.0-rc.2                                ...           6 years ago
  • 5.0.0-rc.1                                ...           6 years ago
  • 5.0.0-rc.0                                ...           6 years ago
  • 5.0.0-alpha.0                                ...           6 years ago
  • 4.0.0-nightly.2020.2.6                                ...           6 years ago
  • 4.0.0-nightly.2020.1.11                                ...           6 years ago
  • 4.0.0-nightly.2020.1.9                                ...           6 years ago
  • 4.0.0-nightly.2020.10.20                                ...           6 years ago
  • 4.0.0-nightly.2020.9.9                                ...           6 years ago
  • 4.0.0-nightly.2020.9.3                                ...           6 years ago
  • 4.0.0-nightly.2020.9.1                                ...           6 years ago
  • 4.0.0-nightly.2020.8.29                                ...           6 years ago
  • 4.0.0-nightly.2020.8.25                                ...           6 years ago
  • 4.0.0-nightly.2020.8.24                                ...           6 years ago
  • 4.0.0-nightly.2020.8.17                                ...           6 years ago
  • 4.0.0-nightly.2020.8.10                                ...           6 years ago
  • 4.0.0-nightly.2020.8.4                                ...           6 years ago
  • 4.0.0-nightly.2020.8.1                                ...           6 years ago
  • 4.0.0-nightly.2020.7.31                                ...           6 years ago
  • 4.0.0-nightly.2020.7.25                                ...           6 years ago
  • 4.0.0-nightly.2020.7.24                                ...           6 years ago
  • 4.0.1                                ...           8 years ago
  • 4.0.0                                ...           8 years ago
  • 4.0.0-rc.2                                ...           9 years ago
  • 4.0.0-rc.0                                ...           9 years ago
  • 2.6.1                                ...           10 years ago
  • 2.6.0                                ...           10 years ago
  • 2.5.0                                ...           10 years ago
  • 2.4.1                                ...           10 years ago
  • 2.4.0                                ...           10 years ago
  • 2.3.6                                ...           10 years ago
  • 2.3.5                                ...           10 years ago
  • 2.3.4                                ...           11 years ago
  • 2.3.3                                ...           11 years ago
  • 2.3.2                                ...           11 years ago
  • 2.3.1                                ...           11 years ago
  • 2.3.0                                ...           11 years ago
  • 2.2.1                                ...           11 years ago
  • 2.2.0                                ...           11 years ago
  • 2.1.0                                ...           11 years ago
  • 2.0.1                                ...           11 years ago
  • 2.0.0                                ...           11 years ago
  • 1.3.1                                ...           11 years ago
  • 1.3.0                                ...           11 years ago
  • 1.2.5                                ...           11 years ago
  • 1.2.4                                ...           11 years ago
  • 1.2.3                                ...           11 years ago
  • 1.2.2                                ...           12 years ago
  • 1.2.1                                ...           12 years ago
  • 1.2.0                                ...           12 years ago
  • 1.1.1                                ...           12 years ago
  • 1.1.0                                ...           12 years ago
  • 1.0.3                                ...           12 years ago
  • 1.0.2                                ...           12 years ago
  • 1.0.1                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
Downloads
Total 286
Today 1
This Week 5
This Month 134
Last Day 1
Last Week 15
Last Month 17
Dependencies (2)
Dev Dependencies (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE