haithembelhaj / sass-inline-svg

node-sass function that inlines SVG files
22 stars 22 forks source link

Optimizer removes the fill set on the svg #2

Closed kozgal closed 7 years ago

kozgal commented 8 years ago

Hi,

I've encountered an issue when using your inliner as a background image. I'm setting a fill on the svg to control its color, but the inliner function removes the styling during optimisation before it returns.

This can be fixed by changing a tiny bit in the inliner function as such:

function inliner(base, opts) {

  opts = assign({}, defaultOptions, opts);

  return function(path, selectors){

    var content = readFileSync(resolve(base, path.getValue()));

    if(selectors && selectors.getLength && selectors.getLength())
      content = changeStyle(content, selectors);

    if(opts.optimize)
      content = new Buffer(optimize(content).data);

    return encode(content);
  }

I'd love it if you could fix this so I can avoid having to go through all the trouble it is to edit and make my own functional package

Thanks in advance, and thanks for publishing this great asset! :)

Nemo

haithembelhaj commented 8 years ago

Hi, thank you for pointing this out! I'm currently on a road trip for 2 month without my laptop. If you are eager to have this fixed, just make a merge request and I will happily integrate it. This would only work for the GitHub repo, for the time being, but not for the npm package as I can't publish to npm right now without my machine.

Again sorry for the inconvenience and thank you for your support :)

haithembelhaj commented 7 years ago

Ohh I completely forgot about this repo. But it's never too late :p @kozgal that was great advice! I updated the package and included you changes. Thank you so much !