You are here

function browsersync_css_alter in Browsersync 8

Same name and namespace in other branches
  1. 8.2 browsersync.module \browsersync_css_alter()
  2. 7 browsersync.module \browsersync_css_alter()

Implements hook_css_alter().

Browsersync does not work with CSS import so we need to force Drupal to embed CSS files as <link> elements.

@link https://github.com/shakyShane/browser-sync/issues/10

File

./browsersync.module, line 46
Code for the Browsersync module.

Code

function browsersync_css_alter(&$css) {
  $system_css_preprocess = \Drupal::config('system.performance')
    ->get('css.preprocess');
  if (browsersync_get_setting('enabled') && !$system_css_preprocess) {
    foreach ($css as $key => $value) {

      // Skip core files.
      if (strpos($value['data'], 'core/') !== 0) {
        $css[$key]['preprocess'] = FALSE;
      }
    }
  }
}