只是遇到一些问题,试图让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 %}
Run Code Online (Sandbox Code Playgroud)
在生产中,它仍然呈现为:
<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" />
Run Code Online (Sandbox Code Playgroud)
尽管如此,当我调用时,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
Run Code Online (Sandbox Code Playgroud)
我正在使用Symfony2的默认Assetic设置.关于可能导致这种情况的任何想法?
小智 15
我有同样的问题,对我来说问题出在我的app.php文件中.我正在加载内核如下:
$kernel = new AppKernel('prod', true);
Run Code Online (Sandbox Code Playgroud)
似乎这导致函数无法在调试模式下运行并组合资产.当我将第二个参数更改为false时,资产成功地组合在生产上并且在dev上保持未组合:
$kernel = new AppKernel('prod', false);
Run Code Online (Sandbox Code Playgroud)
此外,您可以传递combine = true作为参数,以显式请求资产合并,以测试此功能是否正常工作.
| 归档时间: |
|
| 查看次数: |
6292 次 |
| 最近记录: |