Gregory M
Gregory M

Reputation: 494

How to setup Gruntfile / Yeoman to scaffold over a feature-centric directory structure

When creating a new project using Yeoman's angularJS generator (yo angular), the app is initialiazed with the following directory structure:

  • app
    • scripts
      • controllers
        • aFeatureController
        • bFeatureController
      • directives
        • aFeatureDirective
        • bFeatureDirective
    • views
      • aFeatureView
      • bFeatureView

While this traditional MVC structure works well, I find it harder to navigate than a feature -centric structure, where all files related to the same section of the app are living under the same roof. In other words, I'd like to have the following structure instead:

  • app
    • aFeature
      • aFeatureController
      • aFeatureDirective
      • aFeatureView
    • bFeature
      • bFeatureController
      • bFeatureDirective
      • bFeatureView

Is it possible to configure gruntfile and Yeoman so that grunt keeps tasking and Yeoman scaffolding generators still function properly?

Upvotes: 4

Views: 346

Answers (1)

MKhanal
MKhanal

Reputation: 384

The structure you pointed out is generated by the default angular yeoman generator.

For the feature based structure that you want, (which I personally like as well), can be generated by other yeoman generators like generator-cg-angular.

There are quite a few generators which do the same. You can find one that suits you best by searching for angular on yeoman. These generate this structure by default without having to change your grunt or writing a new generator.

Upvotes: 1

Related Questions