Skip to content

Instantly share code, notes, and snippets.

Last active February 23, 2016 12:04
What would you like to do?
A script to minimize Sketch's exported SVG files safely, using SVGO
# Cleanup SVG files exported from Sketch
# Needs SVGO (install by running 'npm install -g svgo')
if [[ -d $1 ]]; then
svgo -f $1 --pretty --disable=convertShapeToPath --enable=removeTitle --enable=removeDesc --enable=removeDoctype --enable=removeEmptyAttrs --enable=removeUnknownsAndDefaults --enable=removeUnusedNS --enable=removeEditorsNSData
elif [[ -f $1 ]]; then
svgo -i $1 --pretty --disable=convertShapeToPath --enable=removeTitle --enable=removeDesc --enable=removeDoctype --enable=removeEmptyAttrs --enable=removeUnknownsAndDefaults --enable=removeUnusedNS --enable=removeEditorsNSData
echo "Usage: svgmin <file> or svgmin <folder>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment