Tree shaking css using angular-cli build / schemantics


Tree shaking css using angular-cli build / schemantics



I am on an angular-cli project. I am facing an issue with the css. This is somewhat a non-code question and deviates from stackoverflow needs of putting code. But hopefully it will not be marked down for closure. Here is the background:



I have a lot of unnecessary css lingering around. I need treeshaking for the unnecessary css during the build process. Is there one that you can help me with.



Here is the background of what is happening:



Options:



I see manual tree shaking is an issue. So I saw there are a few css treeshakers around but since angular cli works with multiple components, I see a need of cli integration of the css tree shaker. I could not find one for cli to merge with build.



Questions: Anyone has suggestion on how to integrate or is there a css-tree shaker community project? I have not worked with schmatics.





What exactly do you mean by treeshaking unnecessary CSS? Could you provide a generic example?
– Andrei Gheorghiu
Jul 1 at 2:41






Like treesharking unused variables and imports using cli
– Gary
Jul 1 at 5:31






Here is someones actual ground work. github.com/simlrh/dead-css-loader let me check what is in store until you reply.
– Gary
Jul 1 at 8:24





Practically, it's neither possible nor practical. You'd need to compile every single variant of the page and it would fail anyway considering CSS preprocessors and ng-class directive. A good CSS shaker would need to understand and apply specificity. Besides, the gain would not be worth the effort. The only hiccup of CSS is loading, not processing. Also, have you conducted any comparison tests of actual improvement? Just repeat same rule 1k times and see if there's any significant difference in load and parse.
– Andrei Gheorghiu
Jul 1 at 9:47


ng-class





Yes, this is what I too was thinking. I was looking at a css cleaner blog. I deciphered you can match css classes in html and ngClass and ngStyle. However, I realised a pure js with css code out of detection will mess it up as well. What options are available if I use a constraint of css classes only in html, ngclass, ngstyle? Would I be able to identify them using the new renderer? Let's ignore the fact that we will ever use a preprocessor.
– Gary
Jul 1 at 12:14










By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to input without newline? (Python)

C++ thread error: no type named ‘type’ MINGW

Analog for TagView in flutter