Angular CLI (Webpack) lazy loading dynamically generated routes
Simplified scenario:
and. User registers in
B. The server will authorize the user and also send back the available routes, that is:
{
new {
itemID = 1,
name = "Users",
parent = "Administration",
icon = "??",
path = "user",
loadChildren = "./adm-user/adm-user.module#AdmUserModule"
//"../adm-user/adm-user.module#AdmUserModule"
},
new {
itemID = 1,
name = "Roles",
parent = "Administration",
icon = "??",
path = "role",
loadChildren = "../adm-user/adm-useaar.module#AdmRoleModule"
}
}
C. My Angular code uses return values ββto manage the router and add return routes.
Problem: It looks like Angular CLI (WebPack) ng server and ng build module don't create any packages for AdmUserModule and AdmRoleModule. I assume this is due to the fact that there are no references to them in the code and it is generated dynamically.
- Note: when I hardcode routes and assembly, I create more packages and everything works fine.
Question: Is there a way to force webpack / Angular CLI to build packages even if it cannot find links in the code? or is there a known solution for this problem?
Question (added): If there is no direct path, can someone explain to me how can I make webpack packages separate Angular modules? This way I can copy these packages manually with the main framework packages and hopefully achieve the same.
source to share
No one has answered this question yet
See similar questions:
or similar: