Skip to content

Commit

Permalink
fix(plugins): reset style missing for antd v5 (#10995)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachScript committed Apr 19, 2023
1 parent f7c8d9c commit cb03d14
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions packages/plugins/src/antd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,21 +249,23 @@ export type IRuntimeConfig = {
return [];
});

// import antd style if antd.import is not configured
api.addEntryImportsAhead(() => {
const isAntd5 = antdVersion.startsWith('5');
const style = api.config.antd.style || 'less';
const imports: Awaited<
ReturnType<Parameters<IApi['addEntryImportsAhead']>[0]['fn']>
> = [];

const doNotImportLess =
(api.config.antd.import && !api.appData.vite) ||
antdVersion.startsWith('5');
if (isAntd5) {
// import antd@5 reset style
imports.push({ source: 'antd/dist/reset.css' });
} else if (!api.config.antd.import || api.appData.vite) {
// import antd@4 style if antd.import is not configured
imports.push({
source: style === 'less' ? 'antd/dist/antd.less' : 'antd/dist/antd.css',
});
}

return doNotImportLess
? []
: [
{
source:
style === 'less' ? 'antd/dist/antd.less' : 'antd/dist/antd.css',
},
];
return imports;
});
};

0 comments on commit cb03d14

Please sign in to comment.