Commit d6cdff97b603f05fb8653534e718ebef112c9cf4
Committed by
GitHub
1 parent
97fe8e20
fix: direct import for antdv subcomponents supported(8b00112d) (#1322)
* fix: direct import for antdv subcomponents supported 修复commit<8b00112d>使用直接过滤部分antdv子组件的方式,导致build后刷新页面子组件样式会丢失的问题。 * Update styleImport.ts * Update styleImport.ts
Showing
1 changed file
with
26 additions
and
16 deletions
build/vite/plugin/styleImport.ts
@@ -14,29 +14,15 @@ export function configStyleImportPlugin(isBuild: boolean) { | @@ -14,29 +14,15 @@ export function configStyleImportPlugin(isBuild: boolean) { | ||
14 | libraryName: 'ant-design-vue', | 14 | libraryName: 'ant-design-vue', |
15 | esModule: true, | 15 | esModule: true, |
16 | resolveStyle: (name) => { | 16 | resolveStyle: (name) => { |
17 | - // 这里是“子组件”列表,无需额外引入样式文件 | 17 | + // 这里是无需额外引入样式文件的“子组件”列表 |
18 | const ignoreList = [ | 18 | const ignoreList = [ |
19 | - 'typography-text', | ||
20 | - 'typography-title', | ||
21 | - 'typography-paragraph', | ||
22 | - 'typography-link', | ||
23 | 'anchor-link', | 19 | 'anchor-link', |
24 | 'sub-menu', | 20 | 'sub-menu', |
25 | 'menu-item', | 21 | 'menu-item', |
26 | 'menu-item-group', | 22 | 'menu-item-group', |
27 | - 'dropdown-button', | ||
28 | 'breadcrumb-item', | 23 | 'breadcrumb-item', |
29 | 'breadcrumb-separator', | 24 | 'breadcrumb-separator', |
30 | - 'input-password', | ||
31 | - 'input-search', | ||
32 | - 'input-group', | ||
33 | 'form-item', | 25 | 'form-item', |
34 | - 'radio-group', | ||
35 | - 'checkbox-group', | ||
36 | - 'layout-sider', | ||
37 | - 'layout-content', | ||
38 | - 'layout-footer', | ||
39 | - 'layout-header', | ||
40 | 'step', | 26 | 'step', |
41 | 'select-option', | 27 | 'select-option', |
42 | 'select-opt-group', | 28 | 'select-opt-group', |
@@ -59,7 +45,31 @@ export function configStyleImportPlugin(isBuild: boolean) { | @@ -59,7 +45,31 @@ export function configStyleImportPlugin(isBuild: boolean) { | ||
59 | 'skeleton-image', | 45 | 'skeleton-image', |
60 | 'skeleton-button', | 46 | 'skeleton-button', |
61 | ]; | 47 | ]; |
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`; | ||
63 | }, | 73 | }, |
64 | }, | 74 | }, |
65 | ], | 75 | ], |