mirror of
https://github.com/mrclay/minify.git
synced 2025-08-12 17:14:24 +02:00
Fixes #271: Allows URI rewriting when handling pre-minified files
This commit is contained in:
@@ -56,6 +56,7 @@ class Minify_CSS {
|
|||||||
public static function minify($css, $options = array())
|
public static function minify($css, $options = array())
|
||||||
{
|
{
|
||||||
$options = array_merge(array(
|
$options = array_merge(array(
|
||||||
|
'compress' => true,
|
||||||
'removeCharsets' => true,
|
'removeCharsets' => true,
|
||||||
'preserveComments' => true,
|
'preserveComments' => true,
|
||||||
'currentDir' => null,
|
'currentDir' => null,
|
||||||
@@ -67,14 +68,16 @@ class Minify_CSS {
|
|||||||
if ($options['removeCharsets']) {
|
if ($options['removeCharsets']) {
|
||||||
$css = preg_replace('/@charset[^;]+;\\s*/', '', $css);
|
$css = preg_replace('/@charset[^;]+;\\s*/', '', $css);
|
||||||
}
|
}
|
||||||
if (! $options['preserveComments']) {
|
if ($options['compress']) {
|
||||||
$css = Minify_CSS_Compressor::process($css, $options);
|
if (! $options['preserveComments']) {
|
||||||
} else {
|
$css = Minify_CSS_Compressor::process($css, $options);
|
||||||
$css = Minify_CommentPreserver::process(
|
} else {
|
||||||
$css
|
$css = Minify_CommentPreserver::process(
|
||||||
,array('Minify_CSS_Compressor', 'process')
|
$css
|
||||||
,array($options)
|
,array('Minify_CSS_Compressor', 'process')
|
||||||
);
|
,array($options)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (! $options['currentDir'] && ! $options['prependRelativePath']) {
|
if (! $options['currentDir'] && ! $options['prependRelativePath']) {
|
||||||
return $css;
|
return $css;
|
||||||
|
@@ -202,9 +202,12 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
|
|||||||
protected function _getFileSource($file, $cOptions)
|
protected function _getFileSource($file, $cOptions)
|
||||||
{
|
{
|
||||||
$spec['filepath'] = $file;
|
$spec['filepath'] = $file;
|
||||||
if ($cOptions['noMinPattern']
|
if ($cOptions['noMinPattern'] && preg_match($cOptions['noMinPattern'], basename($file))) {
|
||||||
&& preg_match($cOptions['noMinPattern'], basename($file))) {
|
if (preg_match('~\.css$~i', $file)) {
|
||||||
$spec['minifier'] = '';
|
$spec['minifyOptions']['compress'] = false;
|
||||||
|
} else {
|
||||||
|
$spec['minifier'] = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new Minify_Source($spec);
|
return new Minify_Source($spec);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user