nathancox/minify

此包的最新版本(v2.0.0)没有可用的许可证信息。

使用Minify(http://code.google.com/p/minify/)压缩CSS需求

安装次数: 110,804

依赖者: 1

建议者: 0

安全性: 0

星标: 26

关注者: 4

分支: 9

开放问题: 4

类型:silverstripe-module

v2.0.0 2017-08-14 22:32 UTC

This package is not auto-updated.

Last update: 2024-09-17 04:09:09 UTC


README

此模块用http://code.google.com/p/minify/压缩CSS文件,替换了部分需求系统。想法和实现基本上是从Tonyair(《http://www.silverstripe.org/general-questions/show/14206》)那里借鉴的。

维护者

Nathan Cox (nathan@flyingmonkey.co.nz)

需求

SilverStripe 3.1+ 检查SS-3.0分支以获取与SS 3.0兼容的版本

安装说明

  1. 将文件放置在SilverStripe安装根目录下的名为"minify"的目录中
  2. 访问你的网站.com/dev/build

用法

该模块将自动用自定义子类替换Requirements后端,因此你不需要进行任何不同的操作。

只需像往常一样使用combine_files来包含CSS即可

<?php

$themeFolder = $this->ThemeDir();
     
$files = array(
	$themeFolder . '/css/layout.css',
	$themeFolder . '/css/typography.css',
	$themeFolder . '/css/form.css'
);

Requirements::combine_files("common.min.css", $files);

你的CSS文件在合并时将自动压缩(就像JavaScript一样)。

默认情况下,CSS文件中的相对URL(例如 background-image:url('../images/background.png');)将被重写,以便合并的CSS文件可以保留在资源中(例如 background-image:url('/themes/mytheme/images/background.png');),但你可以通过在_config.php中放置以下行来关闭此行为:

<?php

Config::inst()->update('Minify_Requirements_Backend', 'rewrite_uris', false);

已知问题

问题跟踪器

致谢

JSMin Minify