angular-cli 可以删除未使用的 css 吗? [英] Can angular-cli remove unused css?

查看:20
本文介绍了angular-cli 可以删除未使用的 css 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我可以使用 angular cli 创建的最小包是通过运行

so far the smallest bundle I can create with angular cli is by running

ng build --aot true -prod

ng build --aot true -prod

我想知道构建过程是否也删除了未使用的 css 类,例如从引导程序?

I was wondering if the build process also removes unused css classes e.g. from bootstrap?

如果不是,我如何向它添加像 purifycss 这样的库?

If not how can I add libraries like purifycss to it?

编辑 2018 年 4 月

我仍然没有找到任何令人满意的解决方案来解决他的问题,尤其是兼容带有 angular 的延迟加载模块的...

I still did not find any satisfying solution to his problem, especially one that is compatible with the lazy loading modules with angular...

干杯

推荐答案

我最近对此做了一些研究,但找不到任何真正安全的方法来删除未使用的 CSS.但是,我遇到了一些可以帮助您检测 VS Code 中的死代码的工具.有一个 extension完美,但看起来很有希望.我还对如何删除未使用的 Angular Material CSS(如果您使用它)进行了一些调查,并创建了一个关于它的视频.您可以在这里查看.

I did some research recently about this, but I could not find any really safe way of how to remove unused CSS. However I came across some tools which would help you detect dead-code in VS Code. There is an extention which is not perfect but looks promising. Also I did some investigation of how to remove unused Angular Material CSS (if you use it) and created a video about it. You can check this out here.

但至少现在(在 2020 年)没有任何可靠的方法可以实现您想要的目标,并且还可以查看 Angular 核心团队成员对此主题的回答

But at least now (in 2020) there is no any reliable way to achieve what you want and see also an answer from Angular Core Team member about this topic

这篇关于angular-cli 可以删除未使用的 css 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆