Created
December 8, 2019 04:49
-
-
Save robdecker/1e44e411910af46756d2297593fd6cd0 to your computer and use it in GitHub Desktop.
[Force <link> instead of <style> @import url() for stylesheets] #d8 #css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_css_alter(). | |
*/ | |
function THEME_css_alter(&$css) { | |
// Use <link> as opposed to <style> @import during development if | |
// css preprocessing is turned off. This will allow tools like | |
// BrowserSync and LiveReload to work properly. | |
$preprocess_css = \Drupal::config('system.performance')->get('css.preprocess'); | |
if (isset($preprocess_css) && $preprocess_css === FALSE) { | |
foreach ($css as $key => $value) { | |
$css[$key]['preprocess'] = FALSE; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment