ng generate doesn't work with multiple apps
See original GitHub issueI have defined two applications in angular-cli.json with names app
(default) and spa
. When I generate any part of app (component, class, etc.), it is always generated to default application folder /app
.
I tried to use option --app spa
, it’s ignored and files are generated to /app
folder.
Any way how to fix that?
angular-cli.json
{
"project": {
"version": "1.3.0",
"name": "web"
},
"apps": [
{
"name": "spa",
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "spa.html",
"main": "main-spa.ts",
"test": "test-spa.ts",
"tsconfig": "tsconfig.json",
"prefix": "spa",
"mobile": false,
"styles": [
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
},
{
"name": "app",
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"prefixInterfaces": false,
"inline": {
"style": false,
"template": false
},
"spec": {
"class": false,
"component": true,
"directive": true,
"module": false,
"pipe": true,
"service": true
}
}
}
Versions.
ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
@angular/cli: 1.3.0
node: 8.2.1
os: linux x64
@angular/common: 2.4.2
@angular/compiler: 2.4.2
@angular/compiler-cli: 2.4.2
@angular/core: 2.4.2
@angular/forms: 2.4.0
@angular/http: 2.4.0
@angular/platform-browser: 2.4.0
@angular/platform-browser-dynamic: 2.4.0
@angular/platform-server: 2.4.2
@angular/router: 3.4.0
@angular/cli: 1.3.0
node -v
v8.2.1
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Use AngularCLI to generate components when there are ...
angular - Use AngularCLI to generate components when there are multiple apps in your project - Stack Overflow. Stack Overflow for Teams –...
Read more >Create Multiple Angular Apps in One Project - TekTutorialsHub
Organize Angular multiple apps in one Project or workspace. You do not have to run npm install, node_modules are shared & and app...
Read more >ng generate - Angular
Run through and reports activity without writing out results. ... ng generate app-shell ... Do not create "spec.ts" test files for the application....
Read more >Deployment - Angular
When you are ready to deploy your Angular application to a remote server, you have various options for deployment. Simple deployment optionslink.
Read more >Create a new project - Angular
Ensure that you aren't already in an Angular workspace directory. · Run ng new followed by the application name as shown here: ·...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In
.angular-cli.json
besides having"name"
property for the app you need also have"appRoot"
as well. e.g."appRoot": "app1"
The reason for this is that hard coded
'app'
is appended to the"root"
from.angular-cli.json
:See https://github.com/angular/angular-cli/blob/master/packages/@angular/cli/utilities/dynamic-path-parser.ts#L16
What is the reason for forcing everything into
'app'
? This is troublesome especially for fitting angular-cli into existing hybrid projects where the “app” folder is already named something else, for example “ng2-app”, and it is silly to have “ng2-app/app”.#showstopper