Skip to content

Commit d6cdff9

Browse files
authored
fix: direct import for antdv subcomponents supported(8b00112) (#1322)
* fix: direct import for antdv subcomponents supported 修复commit<8b00112>使用直接过滤部分antdv子组件的方式,导致build后刷新页面子组件样式会丢失的问题。 * Update styleImport.ts * Update styleImport.ts
1 parent 97fe8e2 commit d6cdff9

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

build/vite/plugin/styleImport.ts

+26-16
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,15 @@ export function configStyleImportPlugin(isBuild: boolean) {
1414
libraryName: 'ant-design-vue',
1515
esModule: true,
1616
resolveStyle: (name) => {
17-
// 这里是“子组件”列表,无需额外引入样式文件
17+
// 这里是无需额外引入样式文件的“子组件”列表
1818
const ignoreList = [
19-
'typography-text',
20-
'typography-title',
21-
'typography-paragraph',
22-
'typography-link',
2319
'anchor-link',
2420
'sub-menu',
2521
'menu-item',
2622
'menu-item-group',
27-
'dropdown-button',
2823
'breadcrumb-item',
2924
'breadcrumb-separator',
30-
'input-password',
31-
'input-search',
32-
'input-group',
3325
'form-item',
34-
'radio-group',
35-
'checkbox-group',
36-
'layout-sider',
37-
'layout-content',
38-
'layout-footer',
39-
'layout-header',
4026
'step',
4127
'select-option',
4228
'select-opt-group',
@@ -59,7 +45,31 @@ export function configStyleImportPlugin(isBuild: boolean) {
5945
'skeleton-image',
6046
'skeleton-button',
6147
];
62-
return ignoreList.includes(name) ? '' : `ant-design-vue/es/${name}/style/index`;
48+
// 这里是需要额外引入样式的子组件列表
49+
// 单独引入子组件时需引入组件样式,否则会在打包后导致子组件样式丢失
50+
const replaceList = {
51+
'typography-text': 'typography',
52+
'typography-title': 'typography',
53+
'typography-paragraph': 'typography',
54+
'typography-link': 'typography',
55+
'dropdown-button': 'dropdown',
56+
'input-password': 'input',
57+
'input-search': 'input',
58+
'input-group': 'input',
59+
'radio-group': 'radio',
60+
'checkbox-group': 'checkbox',
61+
'layout-sider': 'layout',
62+
'layout-content': 'layout',
63+
'layout-footer': 'layout',
64+
'layout-header': 'layout',
65+
'month-picker': 'date-picker',
66+
};
67+
68+
return ignoreList.includes(name)
69+
? ''
70+
: replaceList.hasOwnProperty(name)
71+
? `ant-design-vue/es/${replaceList[name]}/style/index`
72+
: `ant-design-vue/es/${name}/style/index`;
6373
},
6474
},
6575
],

0 commit comments

Comments
 (0)