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 中产物:
![image](https://user-images.githubusercontent.com/7600149/147737441-5f2e3d63-a9bf-487e-95a9-f13a8aca2102.png)
存在的问题
在使用组件库 npm 包中
es
或esm
目录下构建产物时,无论是全量引入还是按需引入方式,都会重复引入多次该文件,比如在 tdesign-vue-starter 中使用时页面大量重复声明了所有 css vars:访问线上体验:https://tdesign.tencent.com/starter/vue/#/dashboard/base
修改后
每个组件中不再单独引入
![image](https://user-images.githubusercontent.com/7600149/147737561-8f138698-1c5a-45b8-8018-ea9d8de362bc.png)
theme/_index.less
中的变量,改为在src/style/index
中引入一次,es 中单个组件中不包括变量声明:只在
![image](https://user-images.githubusercontent.com/7600149/147737658-69dc439e-a53b-4e73-b8ee-838932a00cdf.png)
es/style/index.css
文件中声明一次:可能存在的问题
需要跟所有使用者强调,无论全量/按需引入,都必须引入
![image](https://user-images.githubusercontent.com/7600149/147737777-53fbe0ea-f93e-4f5d-ac3a-54886741baa8.png)
es/style/index.css
,