質問

i am developing a very extensive AngularJS application and for make it extensible and maintenance I use a modular arquitecture like:

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?. The most popular, generator-angular, use a simple structure.

役に立ちましたか?

解決 2

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.

Take a look at this commit.
Essentially it changes * to ** in Gruntfile and moves appropriate files.
Additionally MODULES.coffee file is introduced in some of the later commits. It gathers AngularJS modules creation in one place in a module-folder. 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.

EDIT: Good news! It is planned, for the project structure generated by Yeoman to be feature-based.
Source: https://docs.google.com/presentation/d/1OgABsN24ZWN6Ugng-O8SjF7t0e3liQ9UN7hKdrCr0K8/edit#slide=id.g2b6b56d19_086

他のヒント

With all the js files under scripts folder, you can use requirejs via grunt-bower-requirejs to manage each modules own dependencies.

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top