gpt4 book ai didi

symfony - Assetic 不创建组合链接

转载 作者:行者123 更新时间:2023-12-04 08:50:34 25 4
gpt4 key购买 nike

只是在尝试让 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 设置。关于可能导致这种情况的任何想法?

最佳答案

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

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

这似乎导致该函数无法在 Debug模式下运行并合并 Assets 。当我将第二个参数更改为 false 时, Assets 在生产中成功合并,而在开发中未合并:
$kernel = new AppKernel('prod', false);

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

关于symfony - Assetic 不创建组合链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13261562/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com