Skip to content
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

dimensions is not read from config file if svg is located in /tmp #528

Closed
city41 opened this issue Jan 18, 2021 · 3 comments
Closed

dimensions is not read from config file if svg is located in /tmp #528

city41 opened this issue Jan 18, 2021 · 3 comments

Comments

@city41
Copy link

city41 commented Jan 18, 2021

🐛 Bug Report

When running svgr (from @svgr/cli) against an svg located in /tmp, the dimensions setting in svgr.config.js is ignored

To Reproduce

Small sample case and repro steps here: https://github.com/city41/svgrDimensionsTest

Expected behavior

After running yarn svgr /tmp/sample.svg, I am expecting one of these outcomes:

  • the resulting file is JavaScript and width/height are present. Since the file is located away from svgr.config.js, it should ignore it.
  • the file is in TypeScript and width/height are absent. ie, svgr uses the config file.

The actual result is: file is in TypeScript with width/height set on svg. It seems like svgr is reading typescript: true from the config, but ignoring dimensions: false from the config.

Link to repl or repo (highly encouraged)

https://github.com/city41/svgrDimensionsTest

NOTE

I realize this is obscure and honestly not that important. But it was stumping me for a while, and took me a while to figure out why my output was unexpected. I figured if nothing else, just documenting the issue and letting the team decided what to do makes sense.

Also unlikely /tmp is required, I would expect just being in any other directory would cause this.

Workaround

you can add --no-dimensions when invoking svgr and that gets the expected results.

@open-collective-bot
Copy link

Hey @city41 👋,
Thank you for opening an issue. We'll get back to you as soon as we can.
Please, consider supporting us on Open Collective. We give a special attention to issues opened by backers.
If you use SVGR at work, you can also ask your company to sponsor us ❤️.

@stale
Copy link

stale bot commented Mar 31, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Mar 31, 2021
@city41 city41 closed this as completed Apr 5, 2021
@polarathene
Copy link
Contributor

Out of curiousity, where did you run the command from if not /tmp? I'd look at the reproduction repo, but you've removed it.

I'm interested in what your use-case was for the dimensions: false option, would the SVGO removeDimensions: true config have worked just as well? (it requires both width and height to remove dimensions, and if no viewBox is present it will add one based on those dimensions)

I'm not sure of any reason where dimensions: false provides value over it, and I've proposed that it is removed in a future release as a result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants