Easily turn an SVG file into a Svelte component, Rewritten in Rust.
svg2svelte
parses the svg file's ids for bind:
in the name and converts them into variables we can manipulate later on with an animation library (e.g. [anime.js])
svgo
will need to be installed globallybash
npm i -g svgo # npm
yarn global add svgo # yarn
pnpm add -g svgo # pnpm
build from source
bash
git clone https://github.com/derektata/svg2svelte-rs
cd svg2svelte-rs
make
using cargo
bash
cargo install svg2svelte
```bash
Usage: svg2svelte
Flags: --ts # typescript file
Examples: svg2svelte ball.svg svg2svelte logo.svg --ts ```
NOTE: For Typescript components, The
--ts
flag needs to be positioned after the svg file. Otherwise a regular Javascript component will be generated.
The previous implementation I had written up in shell had issues running cross-platform and only worked on Linux, so I decided to start learning more Rust and this project was born.