postcss-design-px-to-rpx
Advanced tools
Comparing version
{ | ||
"name": "postcss-design-px-to-rpx", | ||
"description": "A CSS post-processor that converts px to uni-app units (rpx, upx).", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"author": "Xiangli Jiaxing <xianglijiaxing@163.com>", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:xljx/postcss-design-px-to-rpx.git" | ||
}, | ||
"bugs": "https://github.com/XiangliJiaxing/postcsss-design-px-to-rpx/issues", | ||
"homepage": "https://github.com/XiangliJiaxing/postcsss-design-px-to-rpx", | ||
"main": "index.js", | ||
@@ -19,2 +25,5 @@ "keywords": [ | ||
], | ||
"scripts": { | ||
"test": "jest spec/*.spec.js" | ||
}, | ||
"dependencies": { | ||
@@ -21,0 +30,0 @@ "object-assign": ">=4.0.1" |
@@ -1,7 +0,7 @@ | ||
# postcss-dp-to-rpx | ||
[](http://badge.fury.io/js/postcss-px-to-viewport) | ||
# postcss-design-px-to-rpx | ||
[](http://badge.fury.io/js/postcss-design-px-to-rpx) | ||
[English](README.md) | 中文 | ||
[English](README.md) | [中文](README_CN.md) | ||
将设计图px尺寸转换为uni-app rpx单位 的 [PostCSS](https://github.com/postcss/postcss) 插件. | ||
将设计图px尺寸转换为uni-app rpx单位 的 [PostCSS](https://github.com/postcss/postcss) 插件. 不支持内联样式! | ||
@@ -52,27 +52,9 @@ ### 输入 | ||
``` | ||
$ npm install postcss-dp-to-rpx --save-dev | ||
$ npm install postcss-design-px-to-rpx --save-dev | ||
``` | ||
或者使用yarn进行安装 | ||
``` | ||
$ yarn add -D postcss-dp-to-rpx | ||
$ yarn add -D postcss-design-px-to-rpx | ||
``` | ||
uni-app 项目下postcss.config.js | ||
```javascript | ||
const path = require('path') | ||
module.exports = { | ||
parser: require('postcss-comment'), | ||
plugins: [ | ||
// 需在postcss-dp-to-rpx 之前 | ||
require('postcss-dp-to-rpx')({ | ||
unitToConvert: "DP", | ||
viewportWidth: 414, | ||
viewportHeight: 750, | ||
viewportUnit: "rpx" | ||
}), | ||
require('@dcloudio/vue-cli-plugin-uni/packages/postcss'), | ||
] | ||
} | ||
``` | ||
### 配置参数 | ||
@@ -125,10 +107,15 @@ | ||
```js | ||
const path = require('path') | ||
module.exports = { | ||
plugins: { | ||
// ... | ||
'postcss-px-to-upx': { | ||
// options | ||
} | ||
} | ||
parser: require('postcss-comment'), | ||
plugins: [ | ||
// 必须在'postcss-dp-to-rpx‘之前 | ||
require('postcss-dp-to-rpx')({ | ||
unitToConvert: "DP", | ||
viewportWidth: 414, | ||
viewportUnit: "rpx" | ||
}), | ||
require('@dcloudio/vue-cli-plugin-uni/packages/postcss'), | ||
] | ||
} | ||
``` |
@@ -1,5 +0,5 @@ | ||
# postcss-dp-to-rpx | ||
[](http://badge.fury.io/js/postcss-px-to-viewport) | ||
# postcss-design-px-to-rpx | ||
[](http://badge.fury.io/js/postcss-design-px-to-rpx) | ||
English | [中文](README_CN.md) | ||
[English](README.md) | [中文](README_CN.md) | ||
@@ -9,7 +9,2 @@ A plugin for [PostCSS](https://github.com/postcss/postcss) that generates uniapp units (rpx) from pixel units. | ||
### Input | ||
### Output | ||
app-plus | ||
```css | ||
@@ -23,2 +18,13 @@ .logo { | ||
``` | ||
### Output | ||
app-plus | ||
```css | ||
.logo{ | ||
height:110.4rpx; | ||
width:110.4rpx; | ||
margin:110.4rpx auto 50px auto; | ||
font-size:calc(8.832rpx * var(--convert-rate)) | ||
} | ||
``` | ||
mp-weixin: | ||
@@ -47,27 +53,9 @@ ```css | ||
``` | ||
$ npm install postcss-dp-to-rpx --save-dev | ||
$ npm install postcss-design-px-to-rpx --save-dev | ||
``` | ||
or yarn | ||
``` | ||
$ yarn add -D postcss-dp-to-rpx | ||
$ yarn add -D postcss-design-px-to-rpx | ||
``` | ||
postcss.config.js | ||
```javascript | ||
const path = require('path') | ||
module.exports = { | ||
parser: require('postcss-comment'), | ||
plugins: [ | ||
// Must to be before postcss-dp-to-rpx | ||
require('postcss-dp-to-rpx')({ | ||
unitToConvert: "DP", | ||
viewportWidth: 414, | ||
viewportHeight: 750, | ||
viewportUnit: "rpx" | ||
}), | ||
require('@dcloudio/vue-cli-plugin-uni/packages/postcss'), | ||
] | ||
} | ||
``` | ||
### Usage | ||
@@ -119,10 +107,15 @@ | ||
```js | ||
const path = require('path') | ||
module.exports = { | ||
plugins: { | ||
// ... | ||
'postcss-px-to-upx': { | ||
// options | ||
} | ||
} | ||
parser: require('postcss-comment'), | ||
plugins: [ | ||
// 必须在'postcss-dp-to-rpx‘之前 | ||
require('postcss-dp-to-rpx')({ | ||
unitToConvert: "DP", | ||
viewportWidth: 414, | ||
viewportUnit: "rpx" | ||
}), | ||
require('@dcloudio/vue-cli-plugin-uni/packages/postcss'), | ||
] | ||
} | ||
``` |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
29532
0.72%1
-50%1
-50%118
-5.6%