-
Notifications
You must be signed in to change notification settings - Fork 6
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
add svgo #16
base: main
Are you sure you want to change the base?
add svgo #16
Conversation
formatting the output sprite would cause the empty symbols to be deleted, which is probably not what we want
can probably use a better description though
@@ -1,3 +1,3 @@ | |||
<svg> | |||
<svg xmlns:xlink="http://www.w3.org/1999/xlink"> |
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.
without this, svgo would yell at me
SvgoParserError: <input>:2:24: Unbound namespace prefix: "xlink"
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.
I'll need to take a deeper dive into this PR before I merge it in, so what will svgo do by default here when ran alongside the plugin?
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.
With this error? Crash the plugin and build sadly :/
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.
Sorry, maybe leaving a comment here specifically was a bad idea, this was more of a general question of what will happen when I merge this PR?
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.
Svgo is an svg minification tool. This implementation will optimize each svg file individually right before it's being included in the spritesheet as a symbol.
Users can opt-out of Svgo or customize its config by passing the options through the plugin config. I don't know if Svgo can pick up the default svgo.config.js
, will have to check.
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.
I think this change is good because using xlink:href
inside an <svg>
element that doesn't have xmlns:xlink
is probably invalid, that's why SVGO was complaining.
svgo?: { | ||
enabled?: boolean; | ||
options?: SvgoConfig; | ||
}; |
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.
Suggestion for an alternative API:
svgo?: { | |
enabled?: boolean; | |
options?: SvgoConfig; | |
}; | |
svgo?: boolean | SvgoConfig |
to simplify, and also eliminate this impossible state:
{
svgo: {
enabled: false,
options: {
// ...
}
}
}
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.
Thanks, that's a pretty good idea
However, I don't know how much you'd be gaining from SVGO in this situation, published icons are probably already optimized. Although many are exported from Figma, so those aren't optimized, for them it might be good to optimize. Also, here you're running SVGO for each icon, and for performance SVGO might be best run once per entire SVG sprite (with special care for default options like Anyway, that's all from me. |
Fixes #7
Description
Add SVGO for svg optimizations.
Type of change
Please mark relevant options with an
x
in the brackets.How Has This Been Tested?
Tested against the remix-vite test app with basic-shapes.svg and looking at the output.
Reviewer checklist
Mark everything that needs to be checked before merging the PR.
Screenshots (if appropriate):
Questions (if appropriate):