提交 eb824626 编写于 作者: Q qiang

fix: postcss-uniapp-plugin support postcss8

上级 97eb491c
......@@ -29,7 +29,6 @@
"mkdirp": "^0.5.1",
"module-alias": "^2.1.0",
"neo-async": "^2.6.1",
"postcss": "^7.0.7",
"postcss-import": "^12.0.1",
"postcss-selector-parser": "^5.0.0",
"postcss-value-parser": "^3.3.1",
......@@ -39,5 +38,8 @@
"wrap-loader": "^0.2.0",
"xregexp": "4.0.0"
},
"peerDependencies": {
"postcss": ">=7"
},
"gitHead": "9e2d0f8e244724fcd64880316c57d837d1778cf8"
}
......@@ -156,7 +156,7 @@ if (process.env.UNI_USING_V3) {
* 转换 upx
* 转换 px
*/
module.exports = postcss.plugin('postcss-uniapp-plugin', function (opts) {
const fn = function (opts) {
opts = {
...defaultOpts,
...opts
......@@ -265,5 +265,20 @@ if (process.env.UNI_USING_V3) {
})
}
}
})
}
const version = Number(require('postcss/package.json').version.split('.')[0])
if (version < 8) {
module.exports = postcss.plugin('postcss-uniapp-plugin', fn)
} else {
module.exports = function (opts) {
return {
postcssPlugin: 'postcss-uniapp-plugin',
Once: fn(opts)
}
}
module.exports.postcss = true
}
}
const postcss = require('postcss')
const selectorParser = require('postcss-selector-parser')
const TAGS = Object.keys(require('@dcloudio/uni-cli-shared').tags)
......@@ -14,8 +13,7 @@ const isInsideKeyframes = function (rule) {
let rewriteUrl
module.exports = postcss.plugin('postcss-uniapp-plugin', function (opts) {
return function (root, result) {
function once (root) {
if (!rewriteUrl) {
rewriteUrl = require('@dcloudio/uni-cli-shared/lib/url-loader').rewriteUrl
}
......@@ -43,5 +41,22 @@ module.exports = postcss.plugin('postcss-uniapp-plugin', function (opts) {
)
}
})
}
const version = Number(require('postcss/package.json').version.split('.')[0])
if (version < 8) {
const postcss = require('postcss')
module.exports = postcss.plugin('postcss-uniapp-plugin', function (opts) {
return once
})
} else {
module.exports = function (opts) {
return {
postcssPlugin: 'postcss-uniapp-plugin',
Once: once
}
})
}
module.exports.postcss = true
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册