Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add NextjsOverrides #181

Merged
merged 20 commits into from
Dec 15, 2023
Merged

feat: add NextjsOverrides #181

merged 20 commits into from
Dec 15, 2023

Conversation

bestickley
Copy link
Collaborator

@bestickley bestickley commented Dec 8, 2023

Fixes #168, #104.
This PR implements NextjsOverrides discussed in #132. This feature enables deep levels of customization over this construct. An incomplete example below. See source code for all options.

new Nextjs(this, 'Nextjs', {
  nextjsPath: './web', // relative path from your project root to NextJS
  overrides: {
    nextjsBucketDeployment: { functionProps: { ... }, ... },
    nextjsDistribution: {
      cloudFrontFunctionProps: { ... },
      distributionProps: { ... },
      edgeFunctionProps: { ... },
      imageBehaviorOptions: { ... },
      imageCachePolicyProps: { ... },
      imageHttpOriginProps: { ... },
      ...
    },
    nextjsDomain: { ... },
    nextjsImage: { ... },
    nextjsInvalidation: { ... },
    nextjsRevalidation: { ... },
    nextjsServer: { ... },
    nextjsStaticAssets: { ... },
  }
});

In the spirit of DRY, I've removed NextjsDefaults favoring NextjsOverrides for reasons stated above. Additionally, NextjsOverrides gives better type support because we're creating optional interfaces based off AWS CDK interfaces that have required properties with @mrgrain/jsii-struct-builder. This prevents having to use any.

@bestickley bestickley marked this pull request as ready for review December 11, 2023 19:09
@bestickley
Copy link
Collaborator Author

@kevin-mitchell, @onhate, would appreciate your review.

@kevin-mitchell
Copy link
Contributor

This looks great, and I love the improvement re: types (and the remove of so many | any!).

Only thing I can really think to add (but am not sure how this would be done) is if there could be something added to the readme / contributions guide about the pattern you established for the optional parameters? Honestly ti's probably not needed, I wasn't familiar with the syntax / tooling you added but quickly looked through .projenrc.ts and was able to figure it out.

@onhate
Copy link
Contributor

onhate commented Dec 12, 2023

I like it better than it is now :)

@bestickley
Copy link
Collaborator Author

@kevin-mitchell, I have added docs on jsii struct builder. great suggestion.
@onhate, awesome. thank you for reviewing!

@bestickley
Copy link
Collaborator Author

@revmischa, approved on Discord. Merging 🚀

@bestickley bestickley merged commit 1524c8e into main Dec 15, 2023
4 checks passed
@bestickley bestickley deleted the feat-overrides branch December 15, 2023 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CustomCDKBucketDeployment lambda - Exited with SIGKILL 9
3 participants