我知道之前已经问了几次,但我仍然无法让我的CSS背景图像与资产配合使用。
我已阅读Path of assets in CSS files in Symfony 2并且所有背景图片都设置为我的CSS中的../ images:
background: url(../images/icons/icon.png)
在我的twig文件中:
{% stylesheets 'bundles/commondirty/css_original/c.css' filter="cssrewrite" %}
<link href="{{ asset_url }}" rel="stylesheet" type="text/css" />
{% endstylesheets %}
我已尝试清除所有缓存内容:
php app/console cache:clear --env=prod --no-debug
rm -rf app/cache/*
rm -rf app/logs/*
然后如上面的答案所述:
php app/console --env=prod assets:install web
php app/console assetic:dump --env=prod
这在本地工作('app.php','app_dev.php'和'/'),但是一旦我将文件上传到生产,它就无法加载背景图像。
本地和生产CSS如下所示我不明白为什么它不起作用?
url("../../bundles/main/images/icons/lrg_coin.png")
权限?我需要重新加载/清除某些内容吗?
修改
dev和prod上的缓存CSS文件指向:
url(../../bundles/main/images/icons/lrg_coin.png)
当我猜测它需要../
而不是../../
时?怎么能改变呢?
答案 0 :(得分:1)
好的,我知道我做错了所以我想发布以备将来参考。我的prod_config.yml中的use_controller设置为false,它覆盖了我的config.yml设置(dev_config.yml使用)
assetic:
use_controller: false
将此更改为true并清除/重新加载我的问题中所述的所有内容解决了该问题。我知道这很简单。