function CssOptimizer::optimize

Same name in other branches
  1. 9 core/lib/Drupal/Core/Asset/CssOptimizer.php \Drupal\Core\Asset\CssOptimizer::optimize()
  2. 8.9.x core/lib/Drupal/Core/Asset/CssOptimizer.php \Drupal\Core\Asset\CssOptimizer::optimize()
  3. 11.x core/lib/Drupal/Core/Asset/CssOptimizer.php \Drupal\Core\Asset\CssOptimizer::optimize()

Overrides AssetOptimizerInterface::optimize

File

core/lib/Drupal/Core/Asset/CssOptimizer.php, line 41

Class

CssOptimizer
Optimizes a CSS asset.

Namespace

Drupal\Core\Asset

Code

public function optimize(array $css_asset) {
    if ($css_asset['type'] != 'file') {
        throw new \Exception('Only file CSS assets can be optimized.');
    }
    if (!$css_asset['preprocess']) {
        throw new \Exception('Only file CSS assets with preprocessing enabled can be optimized.');
    }
    return $this->processFile($css_asset);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.