2013-04-17 33 views
0

第一個Stackoverflow問題。 UHUH!Assetic和Silex - 調試模式

的Silex-Assetic如做我的頭

https://github.com/mheap/Silex-Assetic/blob/master/doc/assetic.rst的文檔和https://github.com/mheap/Silex-Assetic-Demo的演示中,我結束了這一點:

$app->register(new SilexAssetic\AsseticServiceProvider()); 

$app['assetic.path_to_web'] = __DIR__ . '/assets/min'; 
$app['assetic.options'] = array(
    'debug'    => true, 
    'auto_dump_assets' => true 
); 

$app['assetic.filter_manager'] = $app->share(
$app->extend('assetic.filter_manager', function($fm, $app) { 
     $fm->set('yui_css', new Assetic\Filter\Yui\CssCompressorFilter(
      __DIR__ . '/../yuicompressor-2.4.7.jar' 
     )); 
     $fm->set('yui_js', new Assetic\Filter\Yui\JsCompressorFilter(
      __DIR__ . '/../yuicompressor-2.4.7.jar' 
     )); 

     return $fm; 
    }) 
); 

$app['assetic.asset_manager'] = $app->share(
    $app->extend('assetic.asset_manager', function($am, $app) { 
     $am->set('dragons', new Assetic\Asset\AssetCache(
      new Assetic\Asset\GlobAsset(
       __DIR__ . '/assets/css/*.css', 
       array($app['assetic.filter_manager']->get('yui_css')) 
      ), 
      new Assetic\Cache\FilesystemCache(__DIR__ . '/../cache/assetic') 
     )); 
     $am->get('dragons')->setTargetPath('dragons-min.css'); 

     return $am; 
    }) 
);  

而且,在我的樹枝文件:

{% stylesheets '../../assets/css/*.css' filter='yui_css' output='/assets/min/dragons-min.css' %} 
    <link href="{{ asset_url }}" type="text/css" rel="stylesheet" /> 
{% endstylesheets %} 

我有兩個問題:

  • 不知怎的,我以/assets/min/dragons-min.css/assets/min/assets/min/dragons-min.css
  • 龍的min.css文件結束如果我啓用調試模式,我結束了奇怪的文件。

像這樣:

<link href="/assets/min/dragons-min_part_1_bootstrap.min_1.css" type="text/css" rel="stylesheet" /> 
<link href="/assets/min/dragons-min_part_1_main_2.css" type="text/css" rel="stylesheet" /> 
<link href="/assets/min/dragons-min_part_1_normalize_3.css" type="text/css" rel="stylesheet" /> 

如果調試模式是關閉的,我想被調用/assets/css原始文件。並且不要結束重複的目錄結構。

在這個階段,文檔非常糟糕,我對Silex也有點新了。我很想讓我的結構和代碼受到你的挑戰。 :)

+0

您是否嘗試過輸出參數而沒有領先的/ – gunnx

+0

@gunnx就這樣做了。沒有運氣。 –

+0

嘗試設置path_to_web只是'__DIR__' – gunnx

回答