FWeinb / grunt-svgstore

Merge svgs from a folder
MIT License
919 stars 94 forks source link

Feature/custom defs #81

Closed samdbeckham closed 9 years ago

samdbeckham commented 9 years ago

Regarding the discussion on #78 I've created an optional defs option that allows you to append custom defs to the SVG sprite. This allows you to add in things like custom gradients that are unaffected by the id renaming scheme, allowing you to apply them with CSS to any of the icons in the sprite.

FWeinb commented 9 years ago

I would really like if the defs option could be used via a file path instead of a string. I don't like to mix the gruntfile with production data. Maybe call it externalDefs that can potentially contain an array of files or a single file.

samdbeckham commented 9 years ago

That might not be a bad shout, like a defs.xml file or something. Shouldn't be a difficult change.

samdbeckham commented 9 years ago

How's that? I don't know whether to look through the file and check if they're valid defs or whether that's something that we should just leave to the user.

FWeinb commented 9 years ago

Maybe we just use a valid svg but only use the <defs> from it. So the user could create some gradients and test them right in the defs svg but only <defs> are "imported".

samdbeckham commented 9 years ago

I've swapped it out so it looks for a defs block in the linked file and appends them to the sprite. I've added in some better checks as well. This way you can use an SVG like you mentioned or you could use XML provided it has a valid defs block; best of both worlds.

FWeinb commented 9 years ago

This looks awesome. I would like to ship this in 0.5.0