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

Can we please have official support for putting everything in a src directory? #8415

Closed
scf4 opened this issue Aug 18, 2019 · 5 comments
Closed

Comments

@scf4
Copy link

scf4 commented Aug 18, 2019

This feature has been requested for years (e.g., #4789).

We've had workarounds, but now with things like official TS support it's no longer possible because Next assumes so much of our project structure. E.g., we can run "next ./src" but it assumes our tsconfig.json should be under src, too.

Putting everything in a src dir is such a common project structure. It's used by CRA and just about every React starter kit.

Our components dir is on the same level as dist, .babelrc, tsconfig.json, node_modules, pages, next.config.js, static, etc. It's so disorganized!

All we would like is a srcDir option. Why is there so much opposition from the Next team on this?

@sakulstra
Copy link
Contributor

Why is there so much opposite from the Next team on this

I'd guess because a lot of functionality and optimizations in next.js are build around having the pages inside the pages directory.

On a side note - i was upvoting the original issue and just removed my vote.

After using next.js for a while I learned to bend my mental model to see pages folder as routes api only (i guess routes would have been a better name, but no need to change it).
As soon as you want things like page in page modals https://reacttraining.com/react-router/web/example/modal-gallery with next having actual react component code in pages is no longer feasible and you might want to start a reexport pattern like described in the linked issue.

We currently use this structure in a rather big app and developers tend to like(or at least not hate) it.

pages
- index
- auth
-- login
- api
-- graphql
src
- frontend
-- pages
--- Home
--- auth
---- Login
- backend
-- gql
-- models

I'd love to see #7779 to land as we currently still rely on relative import paths.

@scf4
Copy link
Author

scf4 commented Aug 18, 2019

I'd guess because a lot of functionality and optimizations in next.js are build around having the pages inside the pages directory.

I fully understand this, but allowing the directory to be ./src/pages instead of ./pages shouldn't affect any of these optimizations — the pages dir is still treated as a routes api.

@timneutkens
Copy link
Member

Going to close this as this is not following the issue template nor is it an RFC. I'm really not sure why you completely ignored the issue template.

I replied here yesterday that we'll soon add support for src: #4315 (comment)

We'll post a RFC soon.

@timneutkens
Copy link
Member

Posted #8451

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants