The property apps
in the angular-cli.json
file is of array type. If I add a second element into this array, how can I instruct ng build
to build both elements?
Only one root module can exist in an Angular application.
Currently v1.0.0
you can only select app which you want to build by the following command:
ng build -a appName
or
ng build --app appName
you also will need to add name
property to each element in the apps
array so you will have something like that:
"apps": [
{
"name": "app1",
"root": "src/app1root",
...
},
{
"name": "app2",
"root": "src/app2root",
...
},
...
]
also you can use app indices like ng build -a 0
or ng build -a 1
in that case you don't need to specify app names.
From angular-cli sorces you can see that there is no possibility to run all apps in one command, you should either specify index either app name otherwise apps[0]
will be used, so you can't build all apps at the same time using one ng build
call.
I searched the angular-cli
source code but could not find any reference to code that iterates or otherwise inspects the contents of apps
as an array.
As of now (angular-cli
version 1.0.0-beta.15), every instance of code that deals with apps
uses the first element of the array hardcoded (apps[0]
). There does not seem to be a way to select an app to build or alter the default behaviour of using the first element of the array.
The JSON schema for the apps
element describes it this way:
Properties of the different applications in this project.
/**
* Properties of the different applications in this project.
*/
apps?: {
root?: string;
outDir?: string;
assets?: string;
index?: string;
main?: string;
test?: string;
tsconfig?: string;
prefix?: string;
mobile?: boolean;
/**
* Global styles to be included in the build.
*/
styles?: string[];
/**
* Global scripts to be included in the build.
*/
scripts?: string[];
/**
* Name and corresponding file for environment config.
*/
environments?: {
[name: string]: any;
};
}[];
It seems to be a future intent of the project to support building multiple apps out of the same code base but it does not look like it is something doable right now (1.0.0-beta.15 version).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With