This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Compass spriting and config.rb

Discuss installing Symfony 2 here

Compass spriting and config.rb

by ScienceofSpock » Tue Oct 28, 2014 9:56 pm

Howdy yall,
I'm new to Symfony and frameworks in general, and this question is more about Compass (but in the context of a Symfony project) so if this is the wrong place for this question, let me know. I just feel people experienced with Symfony would have a better answer than someone who is only familiar with Compass.

I have a Symfony project, and I have successfully figured out spriting, however, the resulting png sprite sheet is more than twice the size of the original png images. Not a big deal, I thought, I'll just write a small php script to run it through the tinypng api and be done with it. This is where I run into issues. I want to use on_sprite_saved, but my Symfony project has no config.rb file. I have tried creating one, in several different locations and every time they are simply ignored. (I can confirm this by putting garbage in the config.rb file) The sprite sheet is still getting generated just fine, but the same size it always is, not optimized.

What do I need to do to pass a generated sprite sheet to a png optimizer? I could manually run the sprite sheet through tinypng, but I can't be doing that every damn time we push changes to the site, and I thought that was what Assetic/SASS/Compass was for.

I have tried googling for this, and I see quite a few example config.rb files, but virtually no information on how this fits into a Symfony project.

Thanks for any help/advice you can provide,
Keith
ScienceofSpock
Junior Member
 
Posts: 2
Joined: Tue Oct 28, 2014 9:38 pm

Re: Compass spriting and config.rb

by ScienceofSpock » Fri Nov 07, 2014 1:21 am

In case anyone else runs into this issue, I don't think there is a *real* solution, since assetic uses compass through sass (not directly) and instead of being able to create a config.rb with which to use the on_sprite_saved or on_sprite_generated methods, sass creates a temporary config file which contains none of those features, and assetic provides no mechanism to customize the temporary config file.

I worked around this by creating a php script that scans our sprite directory and runs any png files it finds through the tinypng api. I added the script as a console command to our project. It means I have to run one more command every time I run assetic:dump but it's way better than having to compress the image by hand, commit it and push it every time we generate the sprite sheet.
ScienceofSpock
Junior Member
 
Posts: 2
Joined: Tue Oct 28, 2014 9:38 pm