JSPM

postcss-rpxtopx

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q25609F
  • License MIT

A plugin for PostCSS that convert rpx to px

Package Exports

  • postcss-rpxtopx

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-rpxtopx) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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