servicerunner/li3_assetic

此包已被弃用且不再维护。未建议替代包。
最新版本(dev-master)的此包没有可用的许可证信息。

将Assetic的强大功能带给Lithium框架

安装次数: 46,651

依赖者: 0

建议者: 0

安全: 0

星标: 2

关注者: 1

分支: 5

开放问题: 0

类型:lithium-library

dev-master 2014-01-21 05:22 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:26:47 UTC


README

一个包装了Assetic资产管理功能的Lithium辅助工具。感谢@mgcrea提供了一个良好的起点。

安装

通过更新config/bootstrap/libraries.php(提供示例配置)来加载li3_assetic

<?php

// ... snip ...

Libraries::add('li3_assetic', array(
    'optimize'    => Environment::is('production'),
    'debug'       => Environment::is('development'),
    'stylesPath'  => LITHIUM_APP_PATH . '/webroot/css',
    'scriptsPath' => LITHIUM_APP_PATH . '/webroot/js',
    'filters'     => array(
        'lessphp' => new Assetic\Filter\LessphpFilter(),
        'yui_css' => new Assetic\Filter\Yui\CssCompressorFilter(LITHIUM_APP_PATH . '/../tools/yuicompressor-2.4.7.jar'),
        'yui_js'  => new Assetic\Filter\Yui\JsCompressorFilter(LITHIUM_APP_PATH . '/../tools/yuicompressor-2.4.7.jar'),
    )
));

使用

在你的布局中使用此辅助工具的示例

<?php

// Override configuration via helper (ie; top of your layout)
$this->assetic->config(array('optimize' => true));

// Regular call
echo $this->assetic->script(array('libs/json2', 'libs/phonegap-1.2.0', 'libs/underscore', 'libs/mustache'));

// Use some filter (will be processed even in development mode)
echo $this->assetic->style(array('mobile/core'), array('target' => 'mobile.css', 'filters' => array('lessphp')));

// Use glob asset (will be processed even in development mode)
echo $this->assetic->script(array('php/*.js'), array('target' => 'php.js'));

注意:确保你的布局以最终(默认为仅限生产)配置结束

<?php

// Will not overwrite existing compiled file by default
echo $this->assetic->styles(array('target' => 'mobile.css', 'filters' => 'yui_css'));

// Will generated compiled output even if files exists
echo $this->assetic->scripts(array('target' => 'mobile.js', 'filters' => 'yui_js', 'force' => true));