Skip to content

Commit

Permalink
fix(plugins): style provider runtime and win path for antd plugin (#1…
Browse files Browse the repository at this point in the history
…1573)

* chore: copy PR #11347

* fix: antd styleProvider cssinjs win path

* chore: update lock file
  • Loading branch information
fz6m authored Aug 31, 2023
1 parent 98be4ef commit f944814
Show file tree
Hide file tree
Showing 6 changed files with 869 additions and 231 deletions.
6 changes: 5 additions & 1 deletion docs/docs/docs/max/antd.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ export default {

配置 `antd``StyleProvider` 组件,该组件用于兼容低版本浏览器,如 IE11。当你的项目配置了 `legacy` 或者 `targets` 包含 `ie` 时,会自动进行降级处理,不需要手动配置。

**注意:该配置项仅 antd v5 及以上可用**
**注意:**

1. 该配置项仅 antd v5 及以上可用。

2. 降级 CSS 需要依赖 [`@ant-design/cssinjs`](https://ant.design/docs/react/compatible-style-cn) ,若你显示安装了 `antd` ,请安装并确保你的 `@ant-design/cssinjs` 版本与 `antd` 正确对应。

### 运行时配置

Expand Down
4 changes: 4 additions & 0 deletions examples/with-antd-5/.umirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export default {
colorPrimary: '#1DA57A',
},
},
styleProvider: {
hashPriority: 'high',
legacyTransformer: true,
},
// dark: true,
compact: true,
/**
Expand Down
3 changes: 2 additions & 1 deletion examples/with-antd-5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"start": "npm run dev"
},
"dependencies": {
"@ant-design/cssinjs": "^1.16.0",
"@umijs/plugins": "workspace:*",
"antd": "^5.3.0",
"antd": "^5.8.4",
"umi": "workspace:*"
}
}
3 changes: 2 additions & 1 deletion packages/plugins/src/antd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export default (api: IApi) => {

if (cssinjs) {
styleProviderConfig = {
cssinjs,
cssinjs: winPath(cssinjs),
};

if (ieTarget) {
Expand Down Expand Up @@ -295,6 +295,7 @@ export type IRuntimeConfig = {

api.addRuntimePlugin(() => {
if (
api.config.antd.styleProvider ||
api.config.antd.configProvider ||
(appComponentAvailable && api.config.antd.appConfig)
) {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/templates/antd/runtime.ts.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function rootContainer(rawContainer) {
container = (
<StyleProvider
{{#styleProvider.hashPriority}}
hashPriority="{{{styleProviderConfig.hashPriority}}}"
hashPriority="{{{styleProvider.hashPriority}}}"
{{/styleProvider.hashPriority}}
{{#styleProvider.legacyTransformer}}
transformers={[legacyLogicalPropertiesTransformer]}
Expand Down
Loading

1 comment on commit f944814

@vercel
Copy link

@vercel vercel bot commented on f944814 Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.