terraform-aws-next-js
terraform-aws-next-js copied to clipboard
tf-next build ignores distDir inside next.config.js and fails to build
Next js allows to provide a different dist directory inside next.config.js.
because of that getRoutesManifest() fails to find the routes-manifest file and fails the build
Node version: v16.3.0 Next version: v10.0.9 tf-next version: v0.7.0
To replicate:
- set distDir inside next.config.js to distDir: 'dist/.next'
- run tf-next build
Investigating further I found that a config is being passed to the builder function. It's just that the base path is never set:
this is where the default value for .next is set. https://github.com/dealmore/terraform-aws-next-js/blob/main/packages/runtime/src/index.ts#L242
So probably reading the next.config.js file and passing it's distDir to the build command would fix it.
Update nr 2: we also need to set the correct path here: https://github.com/dealmore/terraform-aws-next-js/blob/main/packages/tf-next/src/commands/build.ts#L212
as the temp directory would look for a .next folder at the root.
Hi, thanks for the detailed report. Yep, should be supported, will take a look probably by the end of the week.
Just checking if there is any plan to proceed with this fix? Thank you 😄
Oh yeah, my original estimation didn't age well 😅
Currently busy on pushing the v0.11.0 milestone so I currently have no new ETA on this.
Need to complete #86 first since this touches some code that would also be affected by this change.