feat(sqszx202): configure integral mall deployment
This commit is contained in:
36
single_uniapp22miao/postcss.config.js
Normal file
36
single_uniapp22miao/postcss.config.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const postcss = require('postcss')
|
||||
const uniPostcss = require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
|
||||
|
||||
function toVw(value) {
|
||||
return value.replace(/%\?([+-]?\d+(?:\.\d+)?)\?%/g, (match, number) => {
|
||||
const rpx = Number(number)
|
||||
if (!Number.isFinite(rpx)) {
|
||||
return match
|
||||
}
|
||||
const vw = Number((rpx / 7.5).toFixed(6)).toString()
|
||||
return vw === '0' ? '0' : `${vw}vw`
|
||||
})
|
||||
}
|
||||
|
||||
const rpxPlaceholderToVw = postcss.plugin('rpx-placeholder-to-vw', () => {
|
||||
return root => {
|
||||
root.walkDecls(decl => {
|
||||
if (decl.value && decl.value.includes('%?')) {
|
||||
decl.value = toVw(decl.value)
|
||||
}
|
||||
})
|
||||
|
||||
root.walkAtRules(atRule => {
|
||||
if (atRule.params && atRule.params.includes('%?')) {
|
||||
atRule.params = toVw(atRule.params)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = {
|
||||
plugins: [
|
||||
uniPostcss(),
|
||||
rpxPlaceholderToVw()
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user