postcss-pxtransform 3.7.0-beta.1 → 3.7.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +16 -11
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -50,17 +50,22 @@ module.exports = (options = {}) => {
50
50
  case 'h5': {
51
51
  targetUnit = options.targetUnit ?? 'rem'
52
52
 
53
- if (targetUnit === 'vw') {
54
- options.rootValue = (input) => {
55
- return designWidth(input) / 100
56
- }
57
- } else if (targetUnit === 'px') {
58
- options.rootValue = (input) => (1 / options.deviceRatio[designWidth(input)]) * 2
59
- } else {
60
- // rem
61
- options.rootValue = (input) => {
62
- return (baseFontSize / options.deviceRatio[designWidth(input)]) * 2
63
- }
53
+ switch (targetUnit) {
54
+ case 'vw':
55
+ case 'vmin':
56
+ options.rootValue = (input) => {
57
+ return designWidth(input) / 100
58
+ }
59
+ break
60
+ case 'px':
61
+ options.rootValue = (input) => (1 / options.deviceRatio[designWidth(input)]) * 2
62
+ break
63
+ default:
64
+ // rem
65
+ options.rootValue = (input) => {
66
+ return (baseFontSize / options.deviceRatio[designWidth(input)]) * 2
67
+ }
68
+ break
64
69
  }
65
70
 
66
71
  transUnits.push('rpx')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss-pxtransform",
3
- "version": "3.7.0-beta.1",
3
+ "version": "3.7.0-beta.3",
4
4
  "description": "PostCSS plugin px 转小程序 rpx及h5 rem 单位",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -18,7 +18,7 @@
18
18
  "bugs": {
19
19
  "url": "https://github.com/NervJS/taro/issues"
20
20
  },
21
- "homepage": "https://github.com/NervJS/taro#readme",
21
+ "homepage": "https://github.com/NervJS/taro/tree/next/packages/postcss-pxtransform#readme",
22
22
  "jest": {
23
23
  "testEnvironment": "node",
24
24
  "testEnvironmentOptions": {}