Chore | Improve gatsby-plugin-nginx configurability #747
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's the purpose of this pull request?
This PR improves gatsby-plugin-nginx configurability by allowing it to:
How it works?
The first and second improvements are easy to understand. Basically, there is a new option to add custom nginx rules to the http and server block options. This gives people using this plugin more flexibility in terms of how they use the plugin and their nginx in their infrastructure.
The third point is more interesting. Before this PR, one could only write redirects like this:
Note that
:splat
had to be written exactly like this. Creating redirects with a different name, say:/bar/:rest
broke the plugin. This PR fixes this problem. Also, another problem we are fixing is being able to use variables. Before, one could write:Also, the
:slug
variable name mattered. Now, we can write redirects like:How to test it?
There is a jest that I added some cases like this to test it.