I have an Angular 6 app with routing and lazy loaded modules. The AppModule has a route configuration containing two lazy loaded routes, let's say AModule and BModule.
We have different angular-cli environments configured for prod and dev.
During development of BModule I want the BModule to be available as a route on our development server, but not on our production server.
Therefore, we build the development version of the app using angular-cli environment dev, while the production version is build using environment prod.
So now and in the future it will be usual to have a route configuration for prod and a route configuration for dev which is a superset of the prod configuration.
So what I have done is I created two route configs:
export const prodRoutes: Routes = [
{ path: 'a-module', loadChildren: `app/a-module/a.module#AModule` },
];
export const devRoutes: Routes = [
{ path: 'b-module', loadChildren: `app/b-module/b.module#BModule` },
];
For prod I simply use variable prodRoutes
for my route configuration.
That works fine.
For dev configuration I set routes to [...devRoutes, ...prodRoutes]
.
That does not work properly. It seems that Angular does not understand merged route configurations.
Is there a way to merge multiple route arrays to a single working route configuration?
AModule
insindeb.module
? Because, your dev route config tells me so. Is it a typo or on purpose? - Bunyamin Coskuner