postcss-plugin-constparse 3.5.11 → 3.6.0-beta.1

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 +9 -10
  2. package/package.json +6 -3
package/index.js CHANGED
@@ -1,28 +1,27 @@
1
- const postcss = require('postcss')
2
-
3
- module.exports = postcss.plugin('postcss-plugin-constparse', plugin)
4
-
5
1
  const PLATFORM = {
6
2
  WEAPP: 'weapp',
7
3
  H5: 'h5'
8
4
  }
9
5
 
10
- function plugin (opts) {
6
+ module.exports = (opts = {}) => {
11
7
  opts = Object.assign({
12
8
  constants: [{
13
9
  key: 'taro-tabbar-height',
14
10
  val: '50PX'
15
11
  }]
16
12
  }, opts)
17
- return function (root) {
18
- // 在小程序下会忽略
19
- if (opts.platform === PLATFORM.WEAPP) return
20
- root.walkDecls(function (decl) {
13
+
14
+ return {
15
+ postcssPlugin: 'postcss-plugin-constparse',
16
+ Declaration (decl) {
17
+ if (opts.platform === PLATFORM.WEAPP) return
21
18
  let value = decl.value
22
19
  opts.constants.forEach(item => {
23
20
  value = value.replace(new RegExp(item.key, 'g'), item.val)
24
21
  })
25
22
  decl.value = value
26
- })
23
+ }
27
24
  }
28
25
  }
26
+
27
+ module.exports.postcss = true
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "postcss-plugin-constparse",
3
- "version": "3.5.11",
3
+ "version": "3.6.0-beta.1",
4
4
  "description": "parse constants defined in config",
5
5
  "main": "index.js",
6
6
  "author": "Simba",
7
7
  "license": "MIT",
8
- "dependencies": {
9
- "postcss": "^6.0.22"
8
+ "devDependencies": {
9
+ "postcss": "^8.4.18"
10
+ },
11
+ "peerDependencies": {
12
+ "postcss": "^8.4.18"
10
13
  }
11
14
  }