-
Notifications
You must be signed in to change notification settings - Fork 20
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
SVGO Override Behavior #38
Comments
I suspect this is upstream in SVGR (or SVGO, though that's somewhat less likely). This plugin really doesn't do much other than swap the webpack loader that Gatsby configures for SVGs. We pass all of the other options along to |
I had the same problem. I worked around it by using an SVGO configuration file rather than trying to set the configuration in the Gatsby configuration file. The SVGR docs are pretty terrible but if you look under "SVGO" on this page https://www.smooth-code.com/open-source/svgr/docs/options/#svgo you'll see a link to "see SVGO options", which points here https://gist.github.com/pladaria/69321af86ce165c2c1fc1c718b098dd0 There's no actual documentation there, but I made a guess at its point... I'm not sure if this is an SVGR thing or SVGO thing, but making a file with that same name My multipass: true
plugins:
- removeDimensions: true
- removeViewBox: false I have no idea whether this indicates a bug in SVGR or SVGO. Maybe one of them simply changed how configuration should be given. |
Nice! I’d accept a pull request documenting this approach (deprecating the options entirely). Seems better supported and results in fewer opportunities for things to be lost in translation.
@zabute Would love your thoughts on this too.
…On May 21, 2019, 6:53 PM -0500, Bart Nagel ***@***.***>, wrote:
I had the same problem. I worked around it by using an SVGO configuration file rather than trying to set the configuration in the Gatsby configuration file.
The SVGR docs are pretty terrible but if you look under "SVGO" on this page https://www.smooth-code.com/open-source/svgr/docs/options/#svgo you'll see a link to "see SVGO options", which points here https://gist.github.com/pladaria/69321af86ce165c2c1fc1c718b098dd0
I'm not sure if this is an SVGR thing or SVGO thing, but making a file with that same name .svgo.yml in your project root does the trick. You can then remove the options for gatsby-plugin-svgr from your Gatsby config file.
My .svgo.yml is this:
multipass: true
plugins:
- removeDimensions: true
- removeViewBox: false
I have no idea whether this indicates a bug in SVGR or SVGO. Maybe one of them simply changed how configuration should be given.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@tremby you are totally correct! I've updated our project with the yml file and its working like a charm. |
Thanks, @tremby for this much needed workaround. @coreyward I certainly agree with encouraging using external configuration for now but I'm hesitant to officially break api parity with svgr without figuring out why this is happening and whether or not it can be fixed. Wouldn't you agree? |
@zabute Yeah, ideally we'd support configuration of SVGR as though Gatsby wasn't in the equation, but for the sake of letting folks get on with their work I think we ought to stop providing an example configuration if it isn't working. I think if we want to keep the SVGR options long term we need someone that wants to use them to pitch in and figure out what's going on. I use the out-of-the-box defaults in projects I work on and don't have any spare hours to dive into what's happening here, unfortunately. |
It appears svgo config keys have to be under svgoConfig.plugins. See #40 |
This worked for me
|
I was unable to get the config to keep the
viewBox
over thewidth / height
attributes given an SVG that has both. See this CodePen:https://codesandbox.io/s/gatsbysvgrsvgotest-e4i19
I would expect that this config would yield a
check.svg
SVG that only hasviewBox
:But you can see, it's the reverse and we only see the
width / height
retained on thesvg
element. Does this mean SVGO rule overrides may not be applied?The text was updated successfully, but these errors were encountered: