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

is there a way to ignore svgs that have already been converted in a directory? #54

Closed
CammyMurrie opened this issue Feb 27, 2018 · 9 comments

Comments

@CammyMurrie
Copy link

The use case I have is that the majority of the time I need to amend the created jsx file to peel out <g> tags and the like because where I download them from (InVision i.e. the tool I use at my place of work for designs) can sometimes change the svg's in funny ways which causes problems when rendering.

Given that I never have all the svgs I need at once I don't want to have to run my script for each individual, new svg I bring in to my project but at the moment I am having to due to the current script using the template and overwriting each file that has been created previously.

@gregberge
Copy link
Owner

There is no way to do it out of the box, but I suggest you to convert all svg to a temporary directory, then copy only new files. You can do it using rsync --ignore-existing. So your script will be:

svgr -d icons temp-icons && rsync --ignore-existing temp-icons icons`

I probably missed some rsync options but this is the idea.

Does it solve your problem?

@CammyMurrie
Copy link
Author

Sorry I think i miscommunicated a little...I get the svgs from invision but download them as static files into the project tree rather than retrieve them from a host. Dont know much about rsync but I dont think that helps me in this case?

@gregberge
Copy link
Owner

Yes, so you download them, place it in "svg-folder" then you edit them if you want, then you run "svgr + rsync".

@gregberge
Copy link
Owner

@CammyMurrie does it solve your problem?

@sonaye
Copy link

sonaye commented Aug 9, 2018

This is what I do:

  • I copy any new svgs to src/assets/svg/new.
  • I run yarn svgr.
  • New svgs are moved to src/assets/svg.
  • Created components are placed in src/components/svg.
"svgr": "svgr src/assets/svg/new --out-dir src/components/svg",
"postsvgr": "yarn svgr:sync",
"svgr:sync": "rsync -r src/assets/svg/new/. src/assets/svg",
"postsvgr:sync": "rm -rf src/assets/svg/new && mkdir src/assets/svg/new",

@gregberge
Copy link
Owner

I think we could add this feature in SVGR now. I reopen it!

@gregberge gregberge reopened this Aug 13, 2018
@sonaye
Copy link

sonaye commented Aug 14, 2018

@neoziro Awesome, I am guessing this would require improvements on the config file. Can we add support for outDir and templatePath there too? outDir seems to not work at all from the config file, as for template, it currently only accepts a function.

@gregberge
Copy link
Owner

@sonaye yes of course, we have to fix that.

@gregberge
Copy link
Owner

See #182.

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