Assetic 不创建组合链接 [英] Assetic not creating combined links

查看:21
本文介绍了Assetic 不创建组合链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试让 Assetic 在呈现的网页中生成组合链接时遇到了一些问题.文件本身生成得很好,但在生产环境的网页中,我继续看到单独的文件 URL(在生产中不起作用,因为那些未组合的文件不可用).

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).

在模板中,我有:

{% 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" />

尽管如此,当我调用 php app/console assetic:dump --env=prod 时,我得到:

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

我使用的是 Symfony2 的默认 Assetic 设置.关于可能导致这种情况的任何想法?

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

推荐答案

我遇到了完全相同的问题,对我来说问题出在我的 app.php 文件中.我按如下方式加载内核:

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);

这似乎导致函数无法在调试模式下运行并合并资产.当我将第二个参数更改为 false 时,资产在生产中成功合并,而在开发中未合并:

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);

此外,您可以将 combine=true 作为参数传递以明确请求资产组合,只是为了测试此功能是否正常工作.

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.

这篇关于Assetic 不创建组合链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆