-
Notifications
You must be signed in to change notification settings - Fork 19
feat: enable API, SSR and DSG functions individually as required #375
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
Conversation
✅ Deploy Preview for netlify-plugin-gatsby-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff! Just one small comment
plugin/src/helpers/config.ts
Outdated
// eslint-disable-next-line complexity | ||
function overrideNeededFunctions(neededFunctions) { | ||
const skipAll = | ||
process.env.NETLIFY_SKIP_GATSBY_FUNCTIONS === 'true' || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[sand] I wonder if these repeated checks could be abstracted into a helper that checks for true or 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Have updated. Reads cleaner.
Summary
This PR switches
shouldSkipFunctions()
forgetNeededFunctions()
which checks the skip file generated by gatsby-plugin-netlify and returns an array of the required functions, rather than a boolean.This array is then used throughout the remaining function setup code to enable each function individually.
Backward compatibility is maintained by disabling all functions if an empty skip file is provided and enabling all functions if no skip file exists.
The current env var
NETLIFY_SKIP_GATSBY_FUNCTIONS
still disables all functions as before, but 3 additional env vars have been added to control each function individually:NETLIFY_SKIP_API_FUNCTION
NETLIFY_SKIP_SSR_FUNCTION
NETLIFY_SKIP_DSG_FUNCTION
Test plan
Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal
Fixes #374
The additional functionality in this PR is only possible when paired with this PR in the gatsby-plugin-repo, but the plugin still works as before without it.
Standard checks:
🧪 Once merged, make sure to update the version if needed and that it was
published correctly.