Skip to content

Generating Blueprints in directory other than src/app #5995

@somombo

Description

@somombo

Bug Report or Feature Request (mark with an x)

- [ ] bug report
- [x] feature request

I posted the following question on gitter:

hi.. If I change the name of the folder src/app to say src/lib how do i ensure that if I do things like ng generate component foo, angular-cli will know to place the FooComponent in src/lib? Is there something in .angular-cli.json I'm supposed to update? Thanks

@hansl was kind enough to respond:

@somombo no way right now unfortunately. We’re working on removing the hard coded app directories, in favor of looking at the bootstrapping code.

@hansl that's nice for apps that are bootstrapped. But if someone is working on let's say a library that's bootstrapped only in unit tests, then that will be problematic, unless you are incorporating that into your plans somehow?

I think its not a bad idea to just have an extra configuration in .angular-cli.json to simply change the default name from "app".

Another alternative resolution for the meantime, is to allow the following to command to work
ng generate directive mydirname --export --module="../lib/mylib.module"

It current results in the error:
Invalid path: "../lib/quill.module.ts" cannot be above the "src/app" directory

Ultimately I could see having multiple sibling source directories at "src/*" level such some subset of :

["app", "browser", "server", "common", "android", "ios", "webworker" , "lib"]

(I'll call these "ngRoots", so for example the ngRoot directory server is located at "src/server")

It would be nice to have the ability to generate blueprints by specifying relative which ngRoot directory they should generated in. e.g.

ng generate directive mydirname --export --module="./mylib.module" --ngRoot="./lib"

Thought?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions