2016-09-06 35 views
0

社区不同的图像的URL,Symfony3资产 - 在督促和开发环境

我开始与代码:

myTwig.html.twig

{% block stylesheets %} 
    {% stylesheets filter='?uglifycss' filter='cssrewrite' output='styles/output/main/main.css' 
     'styles/css/home.css' 
     [...] 
    %}<link rel="stylesheet" href="{{ asset_url }}" />{% endstylesheets %} 
{% endblock %} 

home.css

.mainContainer { 
    background: url('../../images/background.png') no-repeat center center; 
} 

如果我运行php app/console assetic:dump --env=prod --no-debug,则symfony在/web/styles/output/main中创建文件main.cssmain_home_1.css。那就对了。但问题是,两个文件中的背景网址不同。

的main.css(PROD)

background:url("../images/background.png") no-repeat center center; 

main_main_1.css(DEV)

background: url("../../../../images/background.png") no-repeat center center; 

在DEV-环境的URL是正确的。但是为什么这些网址在同一个目录中时会有所不同。我该如何解决它?

回答

0

好的,我找到了一个解决方案:我现在使用绝对路径。

.mainContainer { 
    background: url('/images/background.png') no-repeat center center; 
}