Assetic not creating combined links

强颜欢笑 提交于 2019-12-12 07:20:08

问题


Just having a few problems trying to get Assetic to generate the combined links in rendered webpages. The files themselves are being generated fine, but in the web page in the production environment, I'm continuing to see the seperate file URLs (which do not work in production, as those uncombined files aren't available).

In a template, I have:

{% stylesheets
    '@TBundle/Resources/public/css/bootstrap/bootstrap.css'
    '@TBundle/Resources/public/css/bootstrap/bootstrap-responsive.css'

    '@TBundle/Resources/public/css/jquery-selectbox/jquery.selectBox.css'
%}
    <link href="{{ asset_url }}" rel="stylesheet" media="screen" />
{% endstylesheets %}

In production, this is still rendered as:

<link href="/css/2f787d0_bootstrap_1.css" rel="stylesheet" media="screen" />
<link href="/css/2f787d0_bootstrap-responsive_2.css" rel="stylesheet" media="screen" />
<link href="/css/2f787d0_jquery.selectBox_3.css" rel="stylesheet" media="screen" />

Despite that, when I invoke php app/console assetic:dump --env=prod I get:

11:13:43 [dir+] /var/www/tbundle/app/../web/css
11:13:43 [file+] /var/www/tbundle/app/../web/css/2f787d0.css

I'm using the default Assetic settings from Symfony2. Any thoughts on what might be causing this?


回答1:


I had this exact same problem, and for me the issue was in my app.php file. I was loading the kernel as follows:

$kernel = new AppKernel('prod', true);

It appears as though this caused the function to not run in debug mode and combine the assets. When i changed the second argument to false, the assets successfully combined on production and remained uncombined on dev:

$kernel = new AppKernel('prod', false);

Also, you can pass combine=true as an argument to explicitly request that the assets get combined just to test that this functionality is working properly.



来源:https://stackoverflow.com/questions/13261562/assetic-not-creating-combined-links

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!