Skip to content

Instantly share code, notes, and snippets.

@kentcdodds
Last active August 29, 2015 14:01
Show Gist options
  • Save kentcdodds/04f535cc14aa47b6239e to your computer and use it in GitHub Desktop.
Save kentcdodds/04f535cc14aa47b6239e to your computer and use it in GitHub Desktop.
Folder Structure styles

Project Folder Structure

I'd love some feedback on a project folder structure I've been considering/trying out. I just don't know why people aren't doing this already and I think I may just be missing something. Is there a problem with the different.md that I'm just missing. Leave comments below. Thanks for the feedback.

Different Style:

.
└── app
    ├── login
    │   ├── LoginCtrl.html
    │   ├── LoginCtrl.js
    │   ├── LoginCtrl.Test.js
    │   └── LoginCtrl.styl
    └── home
        ├── HomeCtrl.html
        ├── HomeCtrl.js
        ├── HomeCtrl.Test.js
        └── HomeCtrl.styl

Of course the build process would handle putting everything in the dist folder that needs to be there (compiling the styl and excluding the test). I've never seen anyone do this, but it just seems like a better pattern to go for. I'd love some feedback.

More Traditional Style:

.
├── app
│   ├── login
│   │   ├── LoginCtrl.html
│   │   └── LoginCtrl.js
│   └── home
│       ├── HomeCtrl.html
│       └── HomeCtrl.js
├── stylus
│   └── components
│       ├── LoginCtrl.styl
│       └── HomeCtrl.styl
└── test
    ├── login
    │   └── LoginCtrlTest.js
    └── home
        └── HomeCtrlTest.js

With this style, you have to navigate back and forth between your app, stylus, and test directories to get everything for the component in line. Many times (in my experience) the styl files and the test files are not named the same as the component so sometimes it can be more difficult to know where/what those are. But I've seen this is a bunch of repos all over. I'm just not sure where the win is here...

@juanmac
Copy link

juanmac commented May 26, 2014

ngBoilerplate project follows more or less the "Different Style" approach (Check here: ngbp/src/app/home/). In the Philosophy section they explain a little why organize file structure that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment