第一个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也有点新了。我很想让我的结构和代码受到你的挑战。 :)
您是否尝试过输出参数而没有领先的/ – gunnx
@gunnx就这样做了。没有运气。 –
尝试设置path_to_web只是'__DIR__' – gunnx