只是有一些问题,试图让Assetic在渲染的网页中生成组合链接。文件本身可以很好地生成,但在生产环境中的网页中,我继续看到单独的文件URL(它们在生产环境中不起作用,因为那些未合并的文件不可用)。
在模板中,我有:
{% 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 %}
在生产环境中,它仍然呈现为:
<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
时,我得到:
11:13:43 [dir+] /var/www/tbundle/app/../web/css
11:13:43 [file+] /var/www/tbundle/app/../web/css/2f787d0.css
我使用的是Symfony2的默认Assetic设置。有没有想过这可能是什么原因造成的?
发布于 2012-11-11 16:41:10
我遇到了完全相同的问题,对我来说,这个问题在我的app.php文件中。我加载内核的方法如下:
$kernel = new AppKernel('prod', true);
看起来好像这导致函数不能在调试模式下运行并合并资产。当我将第二个参数更改为false时,资产在生产环境中成功组合,而在开发环境中保持不组合:
$kernel = new AppKernel('prod', false);
此外,您还可以将combine=true作为参数传递,以显式地请求组合资产,以测试此功能是否正常工作。
https://stackoverflow.com/questions/13261562
复制相似问题