Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
现状
由于在每个组件目录下都引入了
theme/_index
(css 变量文件),以 button 组件为例:https://github.com/Tencent/tdesign-vue/blob/develop/src/button/style/index.js
https://github.com/Tencent/tdesign-common/blob/develop/style/web/components/button/_index.less#L1
https://github.com/Tencent/tdesign-common/blob/develop/style/web/base.less#L11
引入链路为:
button/_index.less
->/base.less
->theme/_index.less
es 中产物:

存在的问题
在使用组件库 npm 包中
es
或esm
目录下构建产物时,无论是全量引入还是按需引入方式,都会重复引入多次该文件,比如在 tdesign-vue-starter 中使用时页面大量重复声明了所有 css vars:访问线上体验:https://tdesign.tencent.com/starter/vue/#/dashboard/base
修改后
每个组件中不再单独引入

theme/_index.less
中的变量,改为在src/style/index
中引入一次,es 中单个组件中不包括变量声明:只在

es/style/index.css
文件中声明一次:可能存在的问题
需要跟所有使用者强调,无论全量/按需引入,都必须引入

es/style/index.css
,