-
-
Notifications
You must be signed in to change notification settings - Fork 425
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
[docs]: "dimensions" option is misleading #550
Comments
Hey @polarathene 👋, |
This comment has been minimized.
This comment has been minimized.
Investigated this issue further. Some sections repeat stuff from others as I wrote notes ad hoc and tidied up afterwards. Not enough time to revise this to be terser, but the TL;DR should be sufficient. Perhaps remove the config option with a major release when upgrading to SVGO v2 support. Docs should be updated in the meantime.. SourceHere is the actual logic related to the config option: svgr/packages/babel-preset/src/index.js Lines 71 to 73 in fbb4ee5
svgr/packages/plugin-svgo/src/config.js Lines 7 to 15 in fbb4ee5
svgr/packages/babel-preset/src/index.js Lines 78 to 81 in fbb4ee5
As well as requiring default svgr/packages/babel-preset/src/index.js Line 77 in fbb4ee5
Observations
Relevant SVGO config variants:
ProblemAs a new user, I wanted the opposite of B - No
HistoryThe The Jan 2019 docs change seems to be the source of the issue. They cited the mismatch as potential for confusion, which while valid, ignored updating the docs description. This also explains the mixed message the CLI override implies. The correct fix would have been to assign a more clear intent to the variable name ( Scaling behaviour of SVG in
|
So is there a way to keep both dimensions and viewbox? To get it working I had to change
to
at node_modules/@svgr/plugin-svgo/lib/config.js:24 and use
as a config |
🐛 Bug Report
The docs for the option
dimensions
are misleading?It appears that the CLI override is required, which in itself implies the default at least for the CLI is the opposite?
Originally I ran into this via the webpack loader package and used the CLI to verify that nothing else was contributing to the confusion of what the docs
true
default for the given description implied.To Reproduce
icon.svg
from the docs "Getting Started" page:icon.svg
npx @svgr/cli icon.svg
:npx @svgr/cli --no-dimensions icon.svg
:Refer to the
dimensions
option description in docs describing the functionality and that it defaults totrue
. Output implies that is not the case.Verify default is in fact
dimensions: true
from source:svgr/packages/core/src/config.js
Line 4 in fbb4ee5
Expected behavior
By default, the root SVG tag should have thewidth
andheight
attributes removed as implied by the docs description for thedimensions
option.EDIT: Now that I've identified it was originally documented as
false
(as in by default it does not remove dimensions, despite the internal mapping beingdimensions: true
anddimensions: false
actually meaning to enable the removal feature) but later changed to "avoid confusion" by matching the internal bool without updating the docs description.... The expected behaviour is for the docs to be corrected.I'll create a PR 👍
Run
npx envinfo --system --binaries --npmPackages @svgr/core,@svgr/cli,@svgr/webpack,@svgr/rollup --markdown --clipboard
The text was updated successfully, but these errors were encountered: