简体   繁体   English

有一种方法可以与Yeoman,Bower和Grunt一起使用调制AngularJS应用程序

[英]There is a way to use an modulating AngularJS Application with Yeoman, Bower and Grunt

i am developing a very extensive AngularJS application and for make it extensible and maintenance I use a modular arquitecture like: 我正在开发一个非常广泛的AngularJS应用程序,并且为了使其具有可扩展性和维护性,我使用了如下的模块化结构:

cart/
  CartModel.js
  CartService.js
common/
  directives.js
  filters.js
product/
  search/
    SearchResultsController.js
    SearchResultsModel.js
  ProductDetailController.js
  ProductModel.js
  ProductService.js
user/
  LoginController.js
  RegistrationController.js
  UserModel.js
  UserService.js

The file structure above is an example of modular structure in angular. 上面的文件结构是有角度的模块化结构的示例。

The Question 问题

Exist a generator for Yeoman that work with this structured?. 是否存在适用于Yeoman的与此结构化的发电机? The most popular, generator-angular , use a simple structure. 最流行的generator-angular使用简单的结构。

With all the js files under scripts folder, you can use requirejs via grunt-bower-requirejs to manage each modules own dependencies. 对于scripts文件夹下的所有js文件,您可以通过grunt-bower-requirejs使用requirejs来管理每个模块自己的依赖项。

Grunt/yeoman need to be aware of all the modules, but you still get the abstraction and decopuling that you are expecting out of this. Grunt / yeoman需要了解所有模块,但是您仍然可以从中得到期望的抽象和脱皮。

You can simply arrange files like this on your own. 您可以简单地自己安排文件。 Angular generators will stop working properly (which is not a big deal IMHO), but all other stuff available in Yeoman will be unaffected. Angular生成器将停止正常工作(恕我直言,这不是什么大问题),但Yeoman中可用的所有其他内容均不受影响。

Take a look at this commit. 看一下这个提交。
Essentially it changes * to ** in Gruntfile and moves appropriate files. 本质上,它在Gruntfile中将*更改为**并移动了适当的文件。
Additionally MODULES.coffee file is introduced in some of the later commits. 此外,在以后的某些提交中引入了MODULES.coffee文件。 It gathers AngularJS modules creation in one place in a module-folder. 它将AngularJS模块创建聚集在一个模块文件夹中。 It's a custom convention invented for my projects' needs, I don't know if it's a community-acclaimed standard. 这是为我的项目需求发明的自定义约定,我不知道这是否是社区认可的标准。

It's still not perfect: templates and scripts for the same feature-based module reside in 2 separate directory trees - they should be in the same place. 它仍然不是完美的:同一基于功能的模块的模板和脚本位于2个单独的目录树中-它们应位于同一位置。

EDIT: Good news! 编辑:好消息! It is planned, for the project structure generated by Yeoman to be feature-based. 计划将Yeoman生成的项目结构基于功能。
Source: https://docs.google.com/presentation/d/1OgABsN24ZWN6Ugng-O8SjF7t0e3liQ9UN7hKdrCr0K8/edit#slide=id.g2b6b56d19_086 来源: https//docs.google.com/presentation/d/1OgABsN24ZWN6Ugng-O8SjF7t0e3liQ9UN7hKdrCr0K8/edit#slide=id.g2b6b56d19_086

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM