Same name in other branches
- 5.0.x advagg_css_minify/src/Asset/CssMinifier.php \Drupal\advagg_css_minify\Asset\CssMinifier::minifyCssMin()
- 6.0.x advagg_css_minify/src/Asset/CssMinifier.php \Drupal\advagg_css_minify\Asset\CssMinifier::minifyCssMin()
- 8.x-4.x advagg_css_minify/src/Asset/CssMinifier.php \Drupal\advagg_css_minify\Asset\CssMinifier::minifyCssMin()
Processes the contents of a stylesheet through CSSMin for minification.
Parameters
string $contents: The contents of the stylesheet.
Return value
string Minified contents of the stylesheet including the imported stylesheets.
1 call to CssMinifier::minifyCssMin()
- CssMinifier::optimize in advagg_css_minify/
src/ Asset/ CssMinifier.php - Optimize the asset's content.
File
-
advagg_css_minify/
src/ Asset/ CssMinifier.php, line 108
Class
- CssMinifier
- Optimizes a JavaScript asset.
Namespace
Drupal\advagg_css_minify\AssetCode
protected function minifyCssMin($contents) {
if (!class_exists('CSSmin')) {
include drupal_get_path('module', 'advagg_css_minify') . '/yui/CSSMin.inc';
}
$cssmin = new \CSSmin(TRUE);
// Minify the CSS splitting lines after 4k of text.
$contents = $cssmin->run($contents, 4096);
// Replaces @import commands with the actual stylesheet content.
// This happens recursively but omits external files.
$contents = preg_replace_callback('/@import\\s*(?:url\\(\\s*)?[\'"]?(?![a-z]+:)(?!\\/\\/)([^\'"\\()]+)[\'"]?\\s*\\)?\\s*;/', [
$this,
'loadNestedFile',
], $contents);
return $contents;
}