You are here

function scss_compiler_library_info_alter in SCSS/Less Compiler 8

Implements hook_library_info_alter().

File

./scss_compiler.module, line 65
Module compiles scss files into css via scssphp compiler.

Code

function scss_compiler_library_info_alter(&$libraries, $extension) {

  // Find all scss files, and add it extension to file info
  // to use it in hook_css_alter.
  $plugins = \Drupal::service('scss_compiler')
    ->getOption('plugins');
  if (empty($plugins)) {
    return;
  }
  $extensions = array_keys($plugins);
  foreach ($libraries as &$library) {
    if (!empty($library['css'])) {
      foreach ($library['css'] as &$group) {
        foreach ($group as $key => &$file) {
          if (in_array(pathinfo($key, PATHINFO_EXTENSION), $extensions)) {
            $file['namespace'] = $extension;
          }
        }
      }
    }
  }
}