kriswallsmith/assetic — Issue #161: Static asset dumping with png optimization references wrong files
Author: roderik
Created: 2011-11-22 19:51:09+00:00
State: open

This bugreport is a crosspost from http://stackoverflow.com/questions/8225000/static-asset-dumping-with-png-optimisation-references-wrong-files . The problem sounds like a bug in assetic, but i wanted to be more sure before creating a bugreport. The other option is that i'm just doing something wrong :)

So here it goes:

I'm trying to build a project using Symfony2 and all possible optimizations included. One of such is the optimizing of images used in the html. Symfony2 has a bundle Assetic that allows for this using e.g. optipng right from the Twig templates. The docs are here: http://symfony.com/doc/2.0/cookbook/assetic/jpeg_optimize.html

The problem i'm having is that everything works in the dev environment (where all assetic assets are served through a controller) but that the CLI command dumps to a file, not used in the rendered templates.

This is the output when dumping the assets, the files are available afterwards in /web/assetic

Dumping all prod assets.
Debug mode is off.

[file+] /home/projects/dashboard/data/dashboard/app/../web/js/4a3b4dc.js
[file+] /home/projects/dashboard/data/dashboard/app/../web/css/9640074.css
[file+] /home/projects/dashboard/data/dashboard/app/../web/assetic/1d666d2.png
[file+] /home/projects/dashboard/data/dashboard/app/../web/assetic/dfaa6c9.png
[file+] /home/projects/dashboard/data/dashboard/app/../web/assetic/5f2dd31.png

When i view the page these url's are called

Css and js however do work.

My config file:

# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
java: /usr/bin/java
filters:
cssrewrite: ~
closure:
jar: %kernel.root_dir%/Resources/java/compiler.jar
yui_css:
jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
optipng:
apply_to: "\.png$"
level: 3
jpegoptim:
apply_to: "\.jpe?g$"
strip_all: true
twig:
functions:
jpegoptim: { output: images/*.jpg }
optipng: { output: images/*.png }

My twig template: