Skip to content

Instantly share code, notes, and snippets.

@iarry
Last active February 9, 2017 19:10
Show Gist options
  • Save iarry/e7dbe46edab4f4e84db9ddf53f1a458c to your computer and use it in GitHub Desktop.
Save iarry/e7dbe46edab4f4e84db9ddf53f1a458c to your computer and use it in GitHub Desktop.
Optimizes SVG with SVGO, then strips it from all classes, ids, viewbox, removes the style tag, and replaces the svg tag with a g tag to be used within our Icon component. Also deletes the sed backup.
#!/bin/bash
original=$1
svgo $original
sed -i '.svg' 's/<style>[^<]*<\/style>//g; ;s/class="[^"]*" //g; s/ viewBox="[^"]*"//g; s/<svg/<g/g; s/<\/svg>/<\/g>/g; s/id="[^"]*" //g; s/ xmlns="[^"]*"//g' $original
rm $original.svg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment