Same name in other branches
- 6.0.x advagg_css_minify/src/Asset/CssMinifier.php \Drupal\advagg_css_minify\Asset\CssMinifier::minifyCssMin()
- 8.x-3.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 109
Class
- CssMinifier
- Optimizes a JavaScript asset.
Namespace
Drupal\advagg_css_minify\AssetCode
protected function minifyCssMin($contents) {
$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;
}