postcss-rpxtopx

0.1.2 • Public • Published

postcss-rpxtopx Build Status Coverage Status NPM Version License

一个 PostCSS 插件,用于将小程序的 rpx 单位转换为 px

安装

你可以通过 yarnnpm 安装

$ yarn add postcss-rpxtopx --dev
$ npm install postcss-rpxtopx --save-dev

使用

输入/输出

// 输入
h1 {
  margin: 0 0 20rpx;
  font-size: 32rpx;
  line-height: 1.2;
  letter-spacing: 1rpx;
}
 
// 输出
h1 {
  margin: 0 0 20px;
  font-size: 32px;
  line-height: 1.2;
  letter-spacing: 1px;
}

例子

const fs = require('fs');
const postcss = require('postcss');
const rpxtopx = require('postcss-rpxtopx');
const acss = fs.readFileSync('main.acss', 'utf8');
const css = postcss(rpxtopx()).process(acss).css;
 
fs.writeFile('main.css', css, err => {
  if (err) {
    throw err;
  }
  console.log('Css file written.');
});

许可证

MIT

Package Sidebar

Install

npm i postcss-rpxtopx

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

4.79 kB

Total Files

5

Last publish

Collaborators

  • yangmingshan