postcss-unit-to-unit

PostCSS plugin transform special unit to another unit


Keywords
postcss, css, postcss-plugin, unit, rpx, rem, px, postcss-plugins
License
MIT
Install
npm install postcss-unit-to-unit@0.0.1

Documentation

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
    });