第一个堆栈溢出问题。嗯哼!
就像做我的头一样。
在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也有点陌生。我希望你能挑战我的结构和代码。:)
发布于 2014-03-01 23:10:03
我想看看这个回购,它是一个更好的例子,如何集成AsseticServiceProvider。https://github.com/lyrixx/Silex-Kitchen-Edition
https://stackoverflow.com/questions/16050464
复制相似问题