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.
So @fabien0102 has been working on this exact issue actually https://github.com/gatsbyjs/gatsby/pull/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?
That is pretty much exactly the structure I would have proposed ๐ Glad you see value in this also.
Most helpful comment
So @fabien0102 has been working on this exact issue actually https://github.com/gatsbyjs/gatsby/pull/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:
Thoughts?