user3006967
user3006967

Reputation: 3545

how to build angular 7 project with lazy load modules

I just noticed that for Angular 7, if I am building the project with this: ng build --aot, then all fine, and it will generate all the lazy loaded modules separately, but if I use this: ng build --prod, then the lazy loaded module is NOT generated at all under dist folder.

I checked the doc, they said using --lazyModules options, but I tried a lot by passing the lazy module as its value like below:

ng build --aot --progress=true --optimization=true --lazyModules=modules/home/home.module

it is useless and give me error as below:

ERROR in ./$$_lazy_route_resource lazy namespace object Module not found: Error: Can't resolve '/Users/projects/projectname/source/projectnamesrc/app/modules/modules/home/home.module.ngfactory.js' in '/Users/projects/projectname/source/projectname/$$_lazy_route_resource'

So if I am using lazyloading, can I still use --prod parameter?

Thanks

Upvotes: 1

Views: 554

Answers (1)

Ali Maleki
Ali Maleki

Reputation: 300

ng build --base-href /ProjectName/ --prod --build-optimizer --vendor-chunk 

Upvotes: 1

Related Questions