Restore ability to override the build directory (from ".next" default) in static export mode #60178
Replies: 1 comment 2 replies
-
I also have this use case. Currently migrating our application from Pages router to App router for web performance improvement. With Next.js 13.5.6 and Pages router I managed to parallelize the build and the export of our 7k pages to reduce the build time on our CI from around 50 minutes to 10 minutes. Big improvement for us to reduce all the pipelines (MR, realease, etc). I was using the combination of :
to build different sets of pages for each parallel job and
to export them Then I merged the different output directories into one and deployed it in a bucket. But now, with the App router not supporting Going back to 50 minutes of build time is a no go for us, so we are excluding ourselves from the potential App router benefits and web performance optimisation (with RSC for exemple). We also can't upgrade to Next.js v14 for the same reason. So I would really like to know if someone here managed to parallelize the next.js build with App router or really want to bring back the buildDir config option ! PS : this issue about the build being non-deterministic #63201 worries me too |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Configure the directory Next.js writes build files to during static export builds (e.g. from
.next
to.next-test
) to allow completely independent simultaneous builds with dynamic configurations without conflicts caused by all static build files writing to.next
.This was possible Next.js 13 and lower using a combination of the
distDir
configuration andnext export -o <directory>
Non-Goals
No response
Background
In Next.js 13 with this
next.config.js
:We could simultaneously:
next dev
; or build and run with the default configuration withnext build && next export && ws
dotenv -oe .env.test -- next build && dotenv -oe .env.test -- next export -o out-test && PORT=3001 dotenv -oe .env.test -- ws
(
ws
islocal-web-server
).In Next.js 14 the
next export -o
option was removed and merged intodistDir
, but the use case was only partially addressed because crucially production build files are now always written into.next
, with AFAIK no way to override in configuration.This means that the closest we can get to our Next.js 13 setup our Next.js 14
next.config.js
is this:This allows us to simultaneously run with
isDevBuild: true, isTestBuild: false
(writes to.next
) andisDevBuild: true, isTestBuild: true
(written to.next-test
) as we could with Next.js 13.But it does’t work with
isDevBuild: true/false, isTestBuild: false
(writes to.next
andout
for prod builds) andisDevBuild: false, isTestBuild: true
(writes to.next
andout-test
) because the production files are always written into.next
, conflicting with the dev build.I understand the rationale for the changed behaviour in Next.js 14, but this is a regression for our (admittedly uncommon) use case, and IMO it’s potentially confusing that
distDir
usually overrides.next
, but overridesout
when used withoutput: "export"
.Proposal
I’m not sure if this is a use case you want to support, but if so I can think of two possible options:
buildDir
config option that allows configuring the build directory separately fromdistDir
--build-dir
flag tonext build
Beta Was this translation helpful? Give feedback.
All reactions