Skip to content

Commit

Permalink
feat: base 替换remtorpx方式
Browse files Browse the repository at this point in the history
  • Loading branch information
pagnkelly committed Sep 11, 2023
1 parent 5e4b44c commit e57f063
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 174 deletions.
21 changes: 0 additions & 21 deletions packages/unocss-base/build/transRem.js

This file was deleted.

15 changes: 10 additions & 5 deletions packages/unocss-base/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
const { presetUno } = require('@unocss/preset-uno')
const theme = require('./theme')

module.exports = function presetMpx (options = { preflight: false }) {
const remRE = /(-?[\.\d]+)rem/g

module.exports = function presetMpx (options = { preflight: false, baseFontSize: 37.5 }) {
const uno = presetUno(options)
const { baseFontSize } = options
return {
...uno,
name: '@mpxjs/unocss-base',
theme: {
...uno.theme,
...theme
postprocess: (util) => {
util.entries.forEach((i) => {
const value = i[1]
if (typeof value === 'string' && remRE.test(value))
i[1] = value.replace(remRE, (_, p1) => `${p1 * baseFontSize}rpx`)
})
}
}
}
147 changes: 0 additions & 147 deletions packages/unocss-base/lib/theme.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/unocss-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"lib": "lib"
},
"scripts": {
"build": "node ./build/transRem.js"
},
"author": "",
"license": "Apache-2.0",
Expand Down

0 comments on commit e57f063

Please sign in to comment.