admin管理员组文章数量:1294383
Currently, the Angular CLI creates a new ponent by default in the app/{ponentName}/
folder.
Is it possible to configure such that the cli will instead generate new ponent folders in app/ponents/{ponentName}/
folder?
I tried messing around with some variables in the angular-cli.json but with no luck.
Currently, the Angular CLI creates a new ponent by default in the app/{ponentName}/
folder.
Is it possible to configure such that the cli will instead generate new ponent folders in app/ponents/{ponentName}/
folder?
I tried messing around with some variables in the angular-cli.json but with no luck.
Share asked Jul 6, 2016 at 13:59 CarvenCarven 15.7k30 gold badges124 silver badges184 bronze badges2 Answers
Reset to default 10There is nothing like that in place in the CLI for a persistent value. The reason for this is that the style guide suggests not placing all like entities (i.e. ponents, services) in a grouped directory.
With that being said to achieve this you have two options...
- Change the directory of your mand line/terminal to
app/ponents/
and generate from there. The CLI will know your current directory and create relative to that directory - When you generate each ponent from the root of your project (or
src
dir) you can specifyng generate ponent ponents/foo
which will include "ponents" in the path of where the ponent is generated.
"The reason for this is that the style guide suggests not placing all like entities (i.e. ponents, services) in a grouped directory."
I disagree here, though the remendation may have changed on the style guide you posted over the past 7 years. Now the style guide states:
"Do make locating code intuitive and fast."
"To work efficiently you must be able to find files quickly, especially when you do not know (or do not remember) the file names. Keeping related files near each other in an intuitive location saves time. A descriptive folder structure makes a world of difference to you and the people who e after you."
"Do keep a flat folder structure as long as possible."
"Consider creating sub-folders when a folder reaches seven or more files."
I prefer to keep my pipes, services, ponents, pages, etc. grouped together, then well organized within that folder structure. Components shared across pages would go into a "ponents/mon" folder, for example, while ponents belonging to a specific page may be found under "ponents/" with each page having a "root" ponent.
But then, my apps tend to be pretty beastly.
本文标签: javascriptChanging default folder for components in angularcliStack Overflow
版权声明:本文标题:javascript - Changing default folder for components in angular-cli - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741596793a2387460.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论