postcss plugin for convert the unit to another unit
$ npm i postcss-unit-to-unit -D
postcss-unit-to-unit
has some options to config.
{
from: 'rpx',
to: 'px',
multiple: 1,
decimalPlaces: 0,
skip: 'skip',
}
String
, the unit should be replaced, e.g. 'rem'
String
, the unit should be replace with, e.g. 'rem'
Number
, replace value with originalValue * multiple
Number
, the number of decimal places
String
, skip the rule marked as this option.
e.g. { margin: 10px; /* skip me */ }
, if set 'skip me'
, plugin will not convert this rule
const postcss = require('postcss');
const plugin = require('postcss-unit-to-unit');
postcss([plugin({
// pass your options
})]).process(/* your css */)
.then(result => {
// do something
});