Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 2.0 assetic dump produces wrong names in debug mode

I'm compressing my javascripts via assetic (block in twig for all scripts in one dir) which works fine in prod mode. Now i want to use the debug mode for my prod env, so i switch assetic to debug in the config, clear the cache and dump the assets with debug on.

This works for some javascripts but not all. Symfony adds a suffix number to them which is higher (by one) on the website (javascript tag) in opposite to the real file. Sometimes clearing the cache and dumping again solved the problem, but noot this time.

For example: It dumps: /web/js/main_part_3_jquery-ui_6.js But uses: /web/js/main_part_3_jquery-ui_1.js

So how can i solve this?

Edit: The wron suffix doesn't appear on the first request to the site after cleaning the cache.

like image 616
Johni Avatar asked Aug 10 '12 12:08

Johni


2 Answers

Since app/console assetic:dump is sensible for cached yml files - you should clear the cache for dumping assets each time you change configuration.

Best of all is to do it in this sequence:

rm -rf app/cache/*
app/console assets:install web
app/console assetic:dump

Of course, with debug keys, needed environments and so on

like image 112
Vitalii Zurian Avatar answered Nov 03 '22 22:11

Vitalii Zurian


I had a similar problem of multiple generated assets and symfony not including the good one on display.

It was because of busting cache enabled in my case, and it was apparently misconfigured. (apparently it's usefull when you need a new version of your files, for example when you update your .js in dev but don't want to break prod )

So disabling it in config.yml fixed it.

assetic:
    workers:
        cache_busting:
            enabled: false
like image 35
c13303 Avatar answered Nov 03 '22 23:11

c13303