首页 > 解决方案 > How to exclude a sub-application from web-pack bundle during build time in Angular

问题描述

Following studying following blog:

https://medium.com/disney-streaming/combining-multiple-angular-applications-into-a-single-one-e87d530d6527

I created three applications : mainApp,subApp1,subapp2.

SubApp1 and subApp2 applications are created inside the project directory of the main project (using ng g application subApp1 --routing=true command).

And I am able to run the applications successfully.

But my need, which is slightly different from the blog is that, the sub applications need not to be independent but act like an optional project (created specifically for different optional features/functionality) with some specific components which I have to use in the main project.

And also these sub applications have no relevance without the main app. As there could be multiple scenarios as follows:

I want that, after the build of the project, I am able to bunde that sub application in web-pack bundle whose components are will be used in the main application.Need is to exclude the sub application from dist folder when not required.

From some similar questions asked I did following actions, for example :

"exclude": [

    "src/test.ts",

    "src/**/*.spec.ts",

    "projects/subApp1"

    ] 

But I still get modules made in subApps in dist folder after the build.

Let me know if there is some corrections to be done in above steps or any other approach.

标签: angulartypescriptwebpackbuildtsconfig

解决方案


推荐阅读