I have been supporting this massive Angular app and from the time I took over support, I was told "ng build --prod" never works. Of course, we did a couple of things that I am not proud of to go round this issue.
So the detailed error when building for prod has been: -
ERROR in 'router-outlet' is not a known element: 1. If 'router-outlet' is an Angular component, then verify that it is part of this module. 2. If 'router-outlet' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. (" [ERROR ->] ")
A quick Google (I actually did a lot of searching) took me to these places, which have great material about this issue: -
None of that worked for me :(.
I then started working my way through all the app modules and discovered that there were a couple of modules which did not have routing defined. Voila. I added routing to all of these modules and this app is now successfully compiling with the --prod flag.