feat: add Vite plugin at a given index #53
Merged
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.
This PR adds an optional parameter to the
addVitePlugin
helper function to specify an optional index where the plugin should be inserted. This makes it possible to use this helper if a plugin if the plugin to be inserted needs to run first or appear before/after a certain plugin.If the index parameter is not specified, the function will append the plugin to the end of the array just like before.
This PR also adds a test to show the behaviour for inserting plugins at the beggining, middle and end of the array.
Reason for this change:
I need this feature for our Sentry SDK installation wizard. It's pretty simple to do without a high-level helper but I thought I'd contribute it upstream as well as IMO it would be nice to have out of the box. Feel free to close this if you want to take this API into another direction.
Thanks for taking the time to consider this.