bguiz / broccoli-sprite

BroccoliJs plugin that generates CSS image sprites
http://blog.bguiz.com/post/88719320815/broccoli-sprite-released/
16 stars 7 forks source link

nameMapping stylesheet option loosed #15

Open cybernetlab opened 8 years ago

cybernetlab commented 8 years ago

Hi! I want to do some name processing and as it described in docs, nameMapping options is used to do this. But in your code JSON.stringify breaks this option out because it is a function and can't be serialized to JSON.

As a workaround I've use following code:

  var nsgOptions = JSON.parse(JSON.stringify(self.options)); //lazy way to deep clone
  if (self.options.stylesheetOptions && self.options.stylesheetOptions.nameMapping) {
    nsgOptions.stylesheetOptions.nameMapping = self.options.stylesheetOptions.nameMapping;
  }
bguiz commented 8 years ago

@cybernetlab Thanks for reporting this. I have been meaning to do a proper deep clone here for a while now. Can you check if this works for you, on the feature/proper-deep-clone branch?

cybernetlab commented 8 years ago

I'm using broccoli-sprite as dependency of ember-sprite. I've change version as you pointed (with fully removing my node_modeules) but it want work with another error:

$ ember build
version: 2.3.0-beta.1
Build failed.
the surface type is not appropriate for the operation
Error: the surface type is not appropriate for the operation
    at Error (native)

Other strange behaviour is that it output files directly to project root - not into dist folder as it was before. When I've roll back version (with fully remove node_modeules) all works fine.

bguiz commented 8 years ago

@cybernetlab Sorry about that, looks like I was bit over eager there, some properties did indeed need to be copied manually.

I am unable to test this out myself right now, but I have pushed the changes to the same branch, if you want to give that a go.