Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持 css tree shaking #7427

Closed
4 tasks done
liuweiGL opened this issue Mar 24, 2022 · 2 comments
Closed
4 tasks done

支持 css tree shaking #7427

liuweiGL opened this issue Mar 24, 2022 · 2 comments

Comments

@liuweiGL
Copy link
Contributor

liuweiGL commented Mar 24, 2022

Clear and concise description of the problem

很多 ui 库都自动在组件的 index.js 入口文件引入了自身的 css 样式:

// Button/index.js
export { default as Button } from './button'
import  './button.css'

vite 不管是在 dev 还是 build 模式下都不会对 css 进行 tree shaking 处理。

Suggested solution

让 css 文件跟 js 文件根据 sideEffects 保持一致的 tree shaking 行为。

Alternative

No response

Additional context

ant-design/ant-design-mobile#4966
#4389 (comment)

Validations

@bluwy
Copy link
Member

bluwy commented Mar 24, 2022

Duplicate of #4389

@bluwy bluwy marked this as a duplicate of #4389 Mar 24, 2022
@bluwy bluwy closed this as completed Mar 24, 2022
@liuweiGL
Copy link
Contributor Author

import { Button } from 'antd-mobile'
↓↓↓↓↓↓↓↓↓
import Button  from 'antd-mobile/Button '

如果使用 babel-plugin-import 的方式进行“按需加载”,项目复杂的话 optimize 会一直更新:

导致项目无法正常启动:


希望帮忙提供一些解决思路。

@github-actions github-actions bot locked and limited conversation to collaborators Apr 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants