From 8b00112d5a7142bb33b982baade2831647f8e16f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E6=9C=A8?= Date: Sun, 19 Sep 2021 11:14:19 +0800 Subject: [PATCH] fix: direct import for antdv subcomponents supported MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复直接import部分antdv子组件时会在build过程中报错的问题 --- CHANGELOG.zh_CN.md | 1 + build/vite/plugin/styleImport.ts | 47 +++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index 2691775b..4c4218c9 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -19,6 +19,7 @@ - **其它** - 修复多标签在某些情况下关闭页签不会跳转路由的问题 - 修复部分组件可能会造成热更新异常的问题 + - 修复直接`import`部分`antdv`子组件时会在 build 过程中报错的问题,如:TabPane、RadioGroup ## 2.7.2(2021-09-14) diff --git a/build/vite/plugin/styleImport.ts b/build/vite/plugin/styleImport.ts index 786580f8..982f2d73 100644 --- a/build/vite/plugin/styleImport.ts +++ b/build/vite/plugin/styleImport.ts @@ -14,7 +14,52 @@ export function configStyleImportPlugin(isBuild: boolean) { libraryName: 'ant-design-vue', esModule: true, resolveStyle: (name) => { - return `ant-design-vue/es/${name}/style/index`; + // 这里是“子组件”列表,无需额外引入样式文件 + const ignoreList = [ + 'typography-text', + 'typography-title', + 'typography-paragraph', + 'typography-link', + 'anchor-link', + 'sub-menu', + 'menu-item', + 'menu-item-group', + 'dropdown-button', + 'breadcrumb-item', + 'breadcrumb-separator', + 'input-password', + 'input-search', + 'input-group', + 'form-item', + 'radio-group', + 'checkbox-group', + 'layout-sider', + 'layout-content', + 'layout-footer', + 'layout-header', + 'step', + 'select-option', + 'select-opt-group', + 'card-grid', + 'card-meta', + 'collapse-panel', + 'descriptions-item', + 'list-item', + 'list-item-meta', + 'table-column', + 'table-column-group', + 'tab-pane', + 'tab-content', + 'timeline-item', + 'tree-node', + 'skeleton-input', + 'skeleton-avatar', + 'skeleton-title', + 'skeleton-paragraph', + 'skeleton-image', + 'skeleton-button', + ]; + return ignoreList.includes(name) ? '' : `ant-design-vue/es/${name}/style/index`; }, }, ],