5
votes

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.

2
What command do you use for an Assetic dump?Elnur Abdurrakhimov
It's the expected behavior of the assetic debug mode to produce multiples files. Why would you want to use debug mode in prod ? (ie: "Now i want to use the debug mode for my prod env" WTF ?)AdrienBrault
Yes i know that it's the normal behavior. But the problem isn't that it produces multiple files. The problem is that the files have another name as the tag imports them. I have my reasons to use the debug mode in prod. We have a test system in which a design company makes changes in the css and js.Johni

2 Answers

3
votes

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

2
votes

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