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

一个 PostCSS 插件,用于将小程序的 rpx 单位转换为 px
安装
$ 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.');
});