Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugins): style provider runtime and win path for antd plugin #11573

Merged
merged 4 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading