Next.js: how to set .next in another folder?

Created on 25 Jan 2017  路  11Comments  路  Source: vercel/next.js

Hello,

I have my pages folder in folder A and would like .next folder in folder B. I see that next build only accepts one arg. Is it possible to do this?

Most helpful comment

I think the only thing missing is a way to specify the lookup folder when building the pages. The distDir and dir (from custom server config) props are not enough to allow us to take the pages out from src and bundle them in the ../src folder.

All 11 comments

Can you elaborate on the usecase please ?

I have a project with the following structure:

image

whereby I place pages folder under ./src/web. Ideally, I would like to place .next folder under ./web

Unfortunately, there is no way to that unless you manually move it, like mv src/web/.next web/.next.
I'm not sure if we should support the setting since maybe it would be just a problem of preferences ?

I have changed my pages directory to src/pages (like suggested here) and now the _.next_ directory is created within src as well. This is bad because it does not belong there and I have to add this folder as an exception for different tools (like prettier).

Is there still no option to keep it at root?

Wouldn't recommend it. But you can use distDir

Thank you very much @timneutkens

You would not recommend moving pages/ elsewhere? If I should not do it, I will not do it.

Well you're not moving pages, you're moving the Next.js root itself, hence the .next ending up in src

Well, I just would like to have my pages/ within my src/ directory (like all other sources as well)
Is that not possible / not recommended, too?

It's not possible indeed. We're not planning on changing that 馃憤

common convention in a full stack application is to have a client or src folder and pages within it. what's the logic behind requiring pages to be in the project root?

I think the only thing missing is a way to specify the lookup folder when building the pages. The distDir and dir (from custom server config) props are not enough to allow us to take the pages out from src and bundle them in the ../src folder.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wagerfield picture wagerfield  路  3Comments

DvirSh picture DvirSh  路  3Comments

kenji4569 picture kenji4569  路  3Comments

jesselee34 picture jesselee34  路  3Comments

olifante picture olifante  路  3Comments