We have an Angular project with many external libraries which has gradually grown in size to 10 MB so it takes some time to load the whole application.
We are now thinking of splitting the application into multiple lazy loaded modules. However, all the tutorials talk about splitting your application code into multiple JS chunks but not about splitting libraries contained in vendor.bundle.js
into multiple chunks based on the modules where they are used. Just splitting our application code would not save us much trouble since external libraries make up most of the application size.
Most of the libraries our application depend on are only used in a single module so there is no point in having them inside vendor.bundle.js
. How can we split this bundle so the smaller vendor chunks will follow the structure of lazy loaded modules? Is it possible to do this easily by Angular CLI or is it not that common and we need some dirty hacks?