Skip to content
This repository has been archived by the owner. It is now read-only.
DEPRECATED, see https://github.com/cssnano/cssnano | Convert values with PostCSS (e.g. ms -> s)
JavaScript
Branch: master
Clone or download

Latest commit

Latest commit bb97683 Feb 3, 2017

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src fix cssnano/cssnano#342 Feb 3, 2017
.all-contributorsrc Update metadata. Feb 3, 2017
.babelrc Update build process. Jun 6, 2016
.editorconfig
.gitignore Converted the module to ES6 & postcss-value-parser addition. Aug 25, 2015
.travis.yml
CHANGELOG.md Update metadata. Feb 3, 2017
LICENSE-MIT Initial commit. Apr 7, 2015
README.md Update metadata. Feb 3, 2017
package.json 2.6.1 Feb 3, 2017

README.md

postcss-convert-values Build Status NPM version Dependency Status

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.

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.

Contributors

Thanks goes to these wonderful people (emoji key):


Ben Briggs

💻 📖 👀 ⚠️

Bogdan Chadkin

💻 📖 👀 ⚠️

Roman Komarov

🐛

Dmitry Kiselyov

🐛

Charlike Mike Reagent

💻 ⚠️

Vyacheslav Shebanov

📖

Marek ‘saji’ Augustynowicz

💻 ⚠️

Jonny Gerig Meyer

💻 ⚠️

GU Yiling

💻 ⚠️

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

License

MIT © Ben Briggs

You can’t perform that action at this time.