Skip to content

Gavin-Gong/postcss-unit-to-unit

Repository files navigation

postcss-unit-to-unit

Build Status npm version

postcss plugin for convert the unit to another unit

Install

$ npm i postcss-unit-to-unit -D

Options

postcss-unit-to-unit has some options to config.

{
    from: 'rpx',
    to: 'px',
    multiple: 1,
    decimalPlaces: 0,
    skip: 'skip',
}

options.from, default as px

String, the unit should be replaced, e.g. 'rem'

options.to, default as px

String, the unit should be replace with, e.g. 'rem'

options.multiple, default as 1

Number, replace value with originalValue * multiple

options.decimalPlaces, default as 0

Number, the number of decimal places

options.skip, default as skip

String, skip the rule marked as this option. e.g. { margin: 10px; /* skip me */ }, if set 'skip me', plugin will not convert this rule

Usage

const postcss = require('postcss');
const plugin = require('postcss-unit-to-unit');

postcss([plugin({
  // pass your options
})]).process(/* your css */)
    .then(result => {
        // do something
    });

About

postcss plugin for convert the unit to another unit

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published