terraform-aws-next-js icon indicating copy to clipboard operation
terraform-aws-next-js copied to clipboard

tf-next build ignores distDir inside next.config.js and fails to build

Open Stralos opened this issue 3 years ago • 5 comments

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:

  1. set distDir inside next.config.js to distDir: 'dist/.next'
  2. run tf-next build

Stralos avatar Jun 22 '21 11:06 Stralos

Investigating further I found that a config is being passed to the builder function. It's just that the base path is never set:

buildCommand

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.

Stralos avatar Jun 22 '21 11:06 Stralos

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.

Stralos avatar Jun 22 '21 12:06 Stralos

Hi, thanks for the detailed report. Yep, should be supported, will take a look probably by the end of the week.

ofhouse avatar Jun 22 '21 17:06 ofhouse

Just checking if there is any plan to proceed with this fix? Thank you 😄

aaronsisler avatar Nov 11 '21 01:11 aaronsisler

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.

ofhouse avatar Nov 11 '21 17:11 ofhouse