Skip to content

Commit

Permalink
fix!: avoid context helper reference pollution
Browse files Browse the repository at this point in the history
break-change:
1. rename `convertUnitOnEnd` to `convertUnit`
  • Loading branch information
hemengke1997 committed Apr 30, 2024
1 parent 570cdb0 commit c40ed9e
Show file tree
Hide file tree
Showing 12 changed files with 1,571 additions and 730 deletions.
8 changes: 4 additions & 4 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default {
| exclude | `string` \| `RegExp` \| `((filePath: string) => boolean)` \| `null` | null | 忽略的文件路径。参考:[exclude](#exclude) |
| include | `string` \| `RegExp` \| `((filePath: string) => boolean)` \| `null` | null | 包括的文件路径,与 `exclude` 相反,优先级低于 `exclude` |
| disable | `boolean` | false | 关闭插件,可用于动态禁用插件 |
| convertUnitOnEnd | `ConvertUnit` \| `ConvertUnit[]` \| false | false | 插件处理的最后阶段转换单位 |
| convertUnit | `ConvertUnit` \| `ConvertUnit[]` \| false | false | 插件处理的最后阶段转换单位 |

#### propList

Expand Down Expand Up @@ -140,9 +140,9 @@ import pxtorem from '@minko-fe/postcss-pxtorem'
export default {
plugins: [
pxtorem({
convertUnitOnEnd: {
sourceUnit: /px$/i,
targetUnit: 'px',
convertUnit: {
source: /px$/i,
target: 'px',
},
}),
],
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default {
| exclude | `string` \| `RegExp` \| `((filePath: string) => boolean) \| null` | /node_modules/i | The file path to ignore and leave as px. Refer to: [exclude](#exclude) |
| include | `string` \| `RegExp` \| `((filePath: string) => boolean)` \| `null` | null | The file path to convert px to rem, in contrast to `exclude`, priority lower than `exclude`. |
| disable | `boolean` | false | disable plugin, used to disable plugin dynamically |
| convertUnitOnEnd | `ConvertUnit` \| `ConvertUnit[]` \| false | false | convert unit when plugin process end |
| convertUnit | `ConvertUnit` \| `ConvertUnit[]` \| false | false | convert unit when plugin process end |

#### propList

Expand Down Expand Up @@ -139,9 +139,9 @@ import pxtorem from '@minko-fe/postcss-pxtorem'
export default {
plugins: [
pxtorem({
convertUnitOnEnd: {
sourceUnit: /px$/i,
targetUnit: 'px',
convertUnit: {
source: /px$/i,
target: 'px',
},
}),
],
Expand Down
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,29 @@
"postcss": ">=8.0.0"
},
"dependencies": {
"@minko-fe/lodash-pro": "^0.3.0",
"decode-uri-component": "^0.4.1",
"split-on-first": "^3.0.0"
},
"devDependencies": {
"@ant-design/cssinjs": "^1.18.4",
"@commitlint/cli": "^18.6.0",
"@ant-design/cssinjs": "^1.20.0",
"@commitlint/cli": "^18.6.1",
"@minko-fe/commitlint-config": "^2.0.7",
"@minko-fe/eslint-config": "^2.1.2",
"@minko-fe/tsconfig": "^2.0.7",
"@minko-fe/eslint-config": "^2.2.2",
"@minko-fe/tsconfig": "^2.0.8",
"@types/decode-uri-component": "^0.2.2",
"bumpp": "^9.2.0",
"bumpp": "^9.4.1",
"conventional-changelog-cli": "^4.1.0",
"cross-env": "^7.0.3",
"eslint": "^8.56.0",
"eslint": "^8.57.0",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.34",
"postcss": "^8.4.38",
"postcss-nested": "^6.0.1",
"simple-git-hooks": "^2.9.0",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vitest": "^0.34.5",
"simple-git-hooks": "^2.11.1",
"tsup": "^8.0.2",
"typescript": "^5.4.5",
"vite": "^5.2.10",
"vitest": "^1.5.2",
"vitest-e2e": "^0.0.10"
},
"simple-git-hooks": {
Expand Down
3 changes: 2 additions & 1 deletion playground/spa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"modern-flexible": "^0.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-use": "^17.4.0"
"react-use": "^17.4.0",
"react-vant": "^3.3.4"
},
"devDependencies": {
"@minko-fe/postcss-pxtorem": "workspace:*",
Expand Down
12 changes: 9 additions & 3 deletions playground/spa/postcss.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ module.exports = {
config: `${__dirname}/tailwind.config.cjs`,
},
'@minko-fe/postcss-pxtorem': {
convertUnitOnEnd: {
sourceUnit: /px$/i,
targetUnit: 'px',
rootValue: ({ file }) => {
if (file.includes('node_modules/react-vant')) {
return 4
}
return 16
},
convertUnit: {
source: /px$/i,
target: 'px',
},
},
},
Expand Down
6 changes: 6 additions & 0 deletions playground/spa/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useLayoutEffect, useState } from 'react'
import { useWindowSize } from 'react-use'
import { Button } from 'react-vant'
import A from './components/A'
import B from './components/B'
import C from './components/C'
Expand Down Expand Up @@ -54,6 +55,11 @@ function App() {
<C />
<D />
<E />

<div className={'box'}>
<div>Vant</div>
<Button type='primary'>按钮很大</Button>
</div>
</div>
)
}
Expand Down
Loading

0 comments on commit c40ed9e

Please sign in to comment.