Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having a src directory as the root of all source files #814

Closed
0x80 opened this issue Apr 17, 2017 · 2 comments
Closed

Having a src directory as the root of all source files #814

0x80 opened this issue Apr 17, 2017 · 2 comments

Comments

@0x80
Copy link
Contributor

0x80 commented Apr 17, 2017

I consider the use of a src directory a pretty useful convention. Is there a particular reason you choose to not have that structure for Gatsby? It seems a bit clumsy to me having all these different source directories directly in the root of the project.

A src directory makes certain configurations easier to manage since sources are clearly separated from config files, static asset or data and node-modules and such. For example having webpack resolve all directories in src for easy import statements, or running some tool like prettier-eslint over all js files.

Right now I was trying to do just that, and prettier-eslint appears to have a bug where it's not respecting the .eslintignore contents correctly, munching away on my node-modules directory.

When using GraphQL to serve data from files which are fetched from an external API, I would expect those files to live in a location like data next to src, indicating that that might not be part of the repository.

Maybe you have your reasons. I'm curious to know.

@KyleAMathews
Copy link
Contributor

So @fabien0102 has been working on this exact issue actually #802 and we've been discussing this in Discord.

My main problem with his PR has been the idea of adding another configuration option as every bit of configuration has a very high cost — sometimes costs you don't realize until down the road when a configuration option adds all sorts of complexity to adding a new feature or event prevents the new feature from being added altogether.

So no new configuration options unless they're super high value.

Which... setting a different root directory isn't.

But his and your's arguments are persuasive that it'd be a lot simpler if all site src code was gathered under one directory.

So here's a proposed directory structure:

├── .cache // Stuff gets cached here. Shouldn't be under source control.
├── README.md
├── data // dump images, json, csv, yaml, etc. here.
├── gatsby-config.js
├── gatsby-node.js
├── plugins // Additional site-specific plugins
├── src // Everything related to the frontend goes here.
│   ├── components
│   │   └── header.js
|   ├── css
│         └── prism-coy.css
│   ├── html.js
│   ├── layouts
│   │   └── index.js
│   ├── pages
│   ├── templates
│   │   └── blog-post.js
│   └── utils
│       └── typography.js
├── static // Everything in this directory gets copied directly into public
├── public // Output directory

Thoughts?

@0x80
Copy link
Contributor Author

0x80 commented Apr 18, 2017

That is pretty much exactly the structure I would have proposed 😄 Glad you see value in this also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants