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

consider to reduce size of final css file? #2397

Closed
tempurai opened this issue Nov 4, 2018 · 4 comments
Closed

consider to reduce size of final css file? #2397

tempurai opened this issue Nov 4, 2018 · 4 comments

Comments

@tempurai
Copy link

tempurai commented Nov 4, 2018

consider to reduce size of final css file?

Hi, thank you for this awesome lib. Yet, the css file contain a lot of unused styles, including those of components that not been used, which result in 100-200k redundant css data in final output.

Is there any plan to purify css in output process?

@ng-zorro-bot

This comment has been minimized.

@LiadIdan
Copy link
Contributor

LiadIdan commented Nov 8, 2018

@LincanLi if you're using Less/custom theme you can use this workaround for now:

  1. create new folder named ant-design
  2. if you're using custom theme move the theme.less file to the folder and get rid of the import line at the top @import "../node_modules/ng-zorro-antd/ng-zorro-antd.less";
  3. create new components.less file inside the ant-design folder and copy all the imports from node_modules/ng-zorro-antd/components.less file. (make sure to fix the import path for all the components. e.g. @import "./card/style/index.less"; should become @import "../../node_modules/ng-zorro-antd/card/style/index.less";)
  4. comment out all the imports of components that you're not using. (don't comment out the import of core component)
  5. create new index.less file inside the ant-design folder and paste there the following imports:
@import "../../node_modules/ng-zorro-antd/style/index.less";
@import "./components.less";
@import "./theme.less";    <--- only if you're using a custom theme 
  1. add the path of the index.less file to the styles list in the angular.json file, and remove the one of the theme.less if you have it.
  2. if you're adding a new component that you didn't use before just go back to the components.less file and uncomment its import

@tempurai
Copy link
Author

@LiadIdan but much of the redundant css are in "../../node_modules/ng-zorro-antd/style/index.less" file

@vthinkxie vthinkxie self-assigned this Feb 26, 2019
@wzhudev
Copy link
Member

wzhudev commented May 8, 2019

Closed by #3234.

@wzhudev wzhudev closed this as completed May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants