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 was simpler than I expected! I haven’t added a test - I’ve never used vitest, so wasn’t really sure where to start.
There’s one notable difference between this and the webpack plugin’s version - I haven’t included the following calculations:
https://github.com/cascornelissen/svg-spritemap-webpack-plugin/blob/775c4b63cb7e2287201d2331544ed677a549ee84/lib/generate-svg.js#L302
As far as I can tell, these calculations adjust the
viewBox
size on the<view />
elements to add 1/2 the gutter size around the sprite. However, this just results in extra space appearing around the sprite when the-view
is used, so I’m not sure why they added this. In my testing it works much better without that additional spacing.The commit that introduced those calculations is this one: cascornelissen/svg-spritemap-webpack-plugin@6612187. I think it may be a bug that nobody has picked up on because
<view />
is used less frequently than<use />
.