gregberge / svgr

Transform SVGs into React components 🦁
https://react-svgr.com
MIT License
10.58k stars 421 forks source link

Feature request: watch mode in CLI #458

Closed KubaJastrz closed 4 years ago

KubaJastrz commented 4 years ago

🚀 Feature Proposal

I want to have --watch flag in svgr command. It would listen to file system changes for specified files/directories, similarly to postcss-cli, and process svg files to React components.

Motivation

I am using snowpack with React. Snowpack doesn't have any built-in solutions for svgs, but is easily extensible with cli scripts. It has a capability to run commands in development, however, it doesn't provide any events on file system changes, so I can't use svgr command alone to rebuild files automatically.

I am able to accomplish this with chokidar-cli, however, I really feel like this functionality could be a part of svgr package.

Example

  1. have some files: input/tree.svg, input/house.svg, input/sun.svg
  2. run svgr --watch -d output input
  3. all svg files from input get compiled initially
  4. change input/tree.svg
  5. output/Tree.js gets automatically rebuilt, but only this one

Pitch

This can be helpful for my use case. If you feel like my example is not enough, or this functionality belongs in snowpack itself, feel free to close it. I can help with the implementation and testing if needed.

open-collective-bot[bot] commented 4 years ago

Hey @KubaJastrz :wave:, 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 :heart:.

reintroducing commented 6 months ago

@KubaJastrz you closed this as completed but was it? Or did you just decide to handle it manually?

KubaJastrz commented 6 months ago

@reintroducing I don't use any of the tools I mentioned anymore. Feel free to open a new issue.

reintroducing commented 6 months ago

@KubaJastrz are you using something else for this purpose now or just generally no need to do this anymore hence you don’t use it?