2012-04-28 58 views
1

當我在layout.html.php添加這樣的臺詞:Symfony 2資產。不要看到單一的CSS或JS文件

<?php foreach ($view['assetic']->stylesheets(
    array('@AnglerBackendBundle/Resources/public/css/*') 
    ) as $url 
    ): ?> 
    <link rel="stylesheet" href="<?= $view->escape($url) ?>" /> 
<?php endforeach ?> 

配置:

# Assetic Configuration 
assetic: 
    debug:   %kernel.debug% 
    use_controller: false 
    # java: /usr/bin/java 
    filters: 
     cssrewrite: ~ 
     # closure: 
     #  jar: %kernel.root_dir%/java/compiler.jar 
     yui_css: 
      jar: %kernel.root_dir%/java/yuicompressor.jar 
     yui_js: 
      jar: %kernel.root_dir%/java/yuicompressor.jar 

我看到5個標籤與5個資源的開發,但根據鏈接Symfony 2文檔我應該只看到一個文件。 我沒有什麼錯

+0

prod或dev模式?或兩者? – 2012-04-28 21:50:16

+1

你在開發環境中測試它嗎?如果是這樣,這是正常的行爲。 http://symfony.com/doc/current/cookbook/assetic/asset_management.html:「在開發環境中,每個文件仍然是單獨提供的,這樣您就可以更容易地調試問題。但是,在產品環境中,這將呈現爲單個腳本標記。「 – dbrumann 2012-04-28 21:50:49

+0

在這兩種環境中都如此。 – setty 2012-04-29 09:29:17

回答

4

只需把答案在實際的答案:

您需要更改此: $內核=新AppKernel(「刺」,真);

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

第二個參數是調試參數。如果調試關閉,Assetic將只寫入一個文件。