0

The time has come to switch from dev to prod in my app and I am trying to fix all the broken links in css files and etc. And now I am stuck at one part..

So i have a file called optimized.less. Which have this:

#srchFld {background: url(../img/search.png) no-repeat right center;border-radius: 0;padding: 4px;margin: 0;line-height: 16px;}

When doing php app/console assets:install. Everything is ok, the file is generated.

After that, doing php app/console assetic:dump --env=prod --no-debug. Generates the css file for prod. However in the file it generated this:

#srchFld {background: url(../../bundles/mpshop/img/search.png) no-repeat right center;border-radius: 0;padding: 4px;margin: 0;line-height: 16px;}

Now I know for a fact, that the link generated is wrong.. The real problem is, that it generates the link url from somewhere else..

For example:

if i remove the url from my public css file:

#srchFld {background: url() no-repeat right center;border-radius: 0;padding: 4px;margin: 0;line-height: 16px;}

When I dump it still generates the exact same url as before... Why? I remove manually all my cache and etc.. And using phpstorm find in path option there are no other files that use the same image url...

What is going on?

Dominykas55
  • 1,231
  • 14
  • 45
  • Have you tried to [define `assets_base_urls`](http://stackoverflow.com/a/17051101/2257664)? – A.L Mar 18 '16 at 13:09
  • as you are using less, may you show us a bit more of your setup? configs, maybe directory structure, what less-compiler/library you use? – Jojo Mar 18 '16 at 17:57

1 Answers1

0

I think this is due to how you assemble your assets in your template. To enable assetic to properly build your urls in css files, you need to use the cssrewrite filter as described in symfony documentation

Example:

{% stylesheets
    'bundles/mybundle/css/main.css'
    'bundles/mybundle/css/another.css'
    filter='cssrewrite'%}
    <link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}
Jojo
  • 2,720
  • 1
  • 17
  • 24