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

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

问题描述

到目前为止,我可以使用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月

对于他的问题,我仍然没有找到任何令人满意的解决方案,特别是与具有角向的惰性加载模块兼容的解决方案.

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

欢呼

推荐答案

module.export={
  plugins: [
    new ExtractTextPlugin('[name].[contenthash].css'),
    // Make sure this is after ExtractTextPlugin!
    new PurifyCSSPlugin({
      // Give paths to parse for rules. These should be absolute!
      paths: glob.sync(path.join(__dirname, 'app/*.html')),
    })
  ]

};

先安装purifycss Webpack

install purifycss webpack first

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

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