Can Next.js build re-use the .next directory as a cache to only re-build the things that changed?
Unanswered
Borzoi posted this in #help-forum
BorzoiOP
Hi.
Most times you do a build again, only some of the source code changed or you got an error you are trying to fix (so only some of the source code changed ...)
I think it would be very beneficial for the next.js build process to take the .next directory and only re-build the parts that actually changed and just leave the rest.
Is this possible?
If you would cache the .next directory in CI servers (and local) this would speed up everyone's build process by a LOT.
also: Friday cheers!
Most times you do a build again, only some of the source code changed or you got an error you are trying to fix (so only some of the source code changed ...)
I think it would be very beneficial for the next.js build process to take the .next directory and only re-build the parts that actually changed and just leave the rest.
Is this possible?
If you would cache the .next directory in CI servers (and local) this would speed up everyone's build process by a LOT.
also: Friday cheers!
8 Replies
Sounds super over complicated for a development process. In dev only modified code gets rebuilt I think the cons out way the pros.
Regardless of my thoughts though if you feel strongly about this I would open an issue or discussion on the GitHub. Vercel and nextjs don’t actively monitor discord.
Regardless of my thoughts though if you feel strongly about this I would open an issue or discussion on the GitHub. Vercel and nextjs don’t actively monitor discord.
BorzoiOP
@Jboncz Well, it would work for production builds too, right? 🙂
so you can cache the .next dir in a build server
Yeah, but when your building nothing should change in flight, thats the whole purpose of building.
Just launch your pruduction server in dev mode 😄
@Borzoi next build already uses the build folder for optimising build speed, they mention it in their docs. What you are asking is the way docker does it's building, which as Jbconz mentioned is overkill.
Build will use cache from .next