Our project setup doesn't have an immediate sub-folder of app, however, it appears that running ng generate always assume that you have an app folder under the app root folder you specified in .angular-cli.json
Angular CLI: 1.6.0
Node: 7.0.0
OS: darwin x64
Angular:
...
{
"apps": [
{
"name": "client",
"root": "projects/client"
}
]
}
ng g c form-inputs/mike --skip-import --dry-run --app=client
You'll see the output path always assumes an app folder:
create projects/client/app/form-inputs/mike/mike.component.css (0 bytes)
create projects/client/app/form-inputs/mike/mike.component.html (23 bytes)
create projects/client/app/form-inputs/mike/mike.component.spec.ts (614 bytes)
create projects/client/app/form-inputs/mike/mike.component.ts (261 bytes)
I'd like an option to be able to configure whether your project has the app folder or not. Or maybe an option to configure the whole path the component gets created in.
Actually, there is an undocumented option in .angular-cli.json called appRoot which is probably you're looking for.
@PoiScript is right, there's appRoot options for this, see https://github.com/angular/angular-cli/pull/7775.
Using appRoot leads to an error "Workspace needs to be loaded before it is used."
and is not included in the json-schema for angular.json.
@leonadler appRoot is used for angular cli 1.x project. angular cli 6 introduces a new configuration schema. Each projects now has individual root and sourceRoot options, see https://github.com/angular/angular-cli/wiki/angular-workspace
ng generate is adding app to the path by default. How to remove 'app' ?
"root": "",
"sourceRoot": "ui-lib/src",
"projectType": "library",
ng g module dashboard/widget -d
CREATE src/app/dashboard/widget/widget.module.spec.ts (275 bytes)
CREATE src/app/dashboard/widget/widget.module.ts (190 bytes)
I'm having the same issue as @jacobjojan, every time I run ng generate it generates by default in app folder, I want to generate out of app folder, how to do that?
@wasif-digitalnet what about
ng generate module ../my-module
CREATE src/my-module/my-module.module.spec.ts (292 bytes)
CREATE src/my-module/my-module.module.ts (192 bytes)
@giolf I have tried it, I guess there was some issues while generating the project, I made a new project and it's working fine now,
@wasif-digitalnet probably you run that command in a nested folder of your project ?
Anyway I鈥檓 glad to hear that you could solve it
@giolf Your solution worked... Cheers!
@ilivestrong
Cool
This problem is still unresolved.
We have a code-base similar to Angular Material, where the library modules folders are directly beneath the main library folder.
We have recently replaced our custom build systems in favor of the Angular CLI, but when using the ng generate commands, they automatically add either app or lib depending on the project type (application or library).
Why can't this be configurable? Why isn't "sourceRoot" the literal root?
Most helpful comment
@wasif-digitalnet what about
ng generate module ../my-module