gavro / gulp-iconify

'A mystical CSS icon solution', grunticon-like build system.
MIT License
50 stars 22 forks source link

URL encode SVG output. #8

Closed jaywolters closed 9 years ago

jaywolters commented 9 years ago

I need some clarity on how to URL encode the SVG files in the CSS. using SVGO in the command line I can specify "--datauri enc" to get a URL encoded version of the SVG. I have tried to add this to the svgoptions like this with no luck:

svgoOptions: { enabled: true, options: { datauri:"enc" } }

Any advice on how to make this work? TIA

jaywolters commented 9 years ago

I have added a small change to the JS to help me out with my problem for now:

on Line 37: //image.datauri = 'data:'+image.mime+';utf8,'+image.contents.toString('utf-8');

changed to: image.datauri = 'data:'+image.mime+';utf8,'+encodeURIComponent(image.contents.toString('utf-8'));

gavro commented 9 years ago

Hi Jay,

I think you might wanna update your npm modules and/or git repos. This has been addressed about a month ago by @gocsp and already merged (see: https://github.com/gavro/gulp-iconify/pull/4). Odd though, because the svgoOptions were added after this merge...

Current logic can be found here: https://github.com/gavro/gulp-iconify/blob/master/lib/iconify.js#L74

Thnx though :+1:

jaywolters commented 9 years ago

Yes -- it appears that I am trying to solve an old problem. Thank you for pointing this out.