Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

postcss-convert-values

Package Overview
Dependencies
2
Maintainers
8
Versions
65
Issues
File Explorer

Advanced tools

postcss-convert-values

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

    5.1.3latest

Version published
Maintainers
8
Weekly downloads
10,586,338
decreased by-9.99%

Weekly downloads

Changelog

Source

v5.1.3

Bug Fixes

  • fix: do not merge declarations containing custom properties when it might create invalid declarations (2c699341)

Readme

Source

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 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 from px to other absolute length units, such as pc & pt & vice versa.

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.

precision

Type: boolean|number Default: false

Specify any numeric value here to round px 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.

Usage

See the PostCSS documentation for examples for your environment.

Contributors

See CONTRIBUTORS.md.

License

MIT © Ben Briggs

Keywords

FAQs

What is postcss-convert-values?

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

Is postcss-convert-values popular?

The npm package postcss-convert-values receives a total of 10,007,728 weekly downloads. As such, postcss-convert-values popularity was classified as popular.

Is postcss-convert-values well maintained?

We found that postcss-convert-values demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 8 open source maintainers collaborating on the project.

Last updated on 28 Oct 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc