Processes the contents of a stylesheet through CSSMin for minification.
Paramètres
string $contents: The contents of the stylesheet.
Return value
string Minified contents of the stylesheet including the imported stylesheets.
1 call to CssOptimizer::processCssMin()
- CssOptimizer::loadFile dans advagg_css_minify/
src/ Asset/ CssOptimizer.php - Loads the stylesheet and resolves all @import commands.
Fichier
-
advagg_css_minify/
src/ Asset/ CssOptimizer.php, line 208
Classe
- CssOptimizer
- Optimizes a CSS asset.
Namespace
Drupal\advagg_css_minify\AssetCode
protected function processCssMin($contents) {
$contents = $this->clean($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;
}