Last active
November 11, 2020 01:16
-
-
Save robdecker/7258774 to your computer and use it in GitHub Desktop.
[No theme css/js in .info since core's css/js aggregation sometimes breaks themes] #d7
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
<?php | |
// Theme serves either minified css/js or uncompressed css/js. | |
$conf['theme_minified_css'] = TRUE; | |
$conf['theme_minified_js'] = TRUE; | |
if (defined('PANTHEON_ENVIRONMENT')) { | |
switch (PANTHEON_ENVIRONMENT) { | |
case 'dev': | |
$conf['theme_minified_css'] = FALSE; | |
$conf['theme_minified_js'] = FALSE; | |
break; | |
case 'test': | |
$conf['theme_minified_css'] = TRUE; | |
$conf['theme_minified_js'] = TRUE; | |
break; | |
case 'live': | |
$conf['theme_minified_css'] = TRUE; | |
$conf['theme_minified_js'] = TRUE; | |
break; | |
} | |
} |
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
<?php | |
function THEME_preprocess_html(&$vars) { | |
// We don't include our css/js in the theme's .info since we minimize it ourselves w/ Grunt. | |
$min_css = variable_get('theme_minified_css'); | |
$min_js = variable_get('theme_minified_js'); | |
$css_options = array( | |
'group' => CSS_THEME, | |
'every_page' => TRUE, | |
'weight' => 9999, | |
'preprocess' => FALSE, | |
); | |
$js_options = array( | |
'group' => JS_THEME, | |
'every_page' => TRUE, | |
'weight' => 9999, | |
'preprocess' => FALSE, | |
); | |
if ($min_css) { | |
drupal_add_css(path_to_theme() . '/css/all.min.css', $css_options); | |
} | |
else { | |
drupal_add_css(path_to_theme() . '/css/maintenance.css', $css_options); | |
drupal_add_css(path_to_theme() . '/css/style.css', $css_options); | |
} | |
if ($min_js) { | |
drupal_add_js(path_to_theme() . '/js/all.min.js', $js_options); | |
} | |
else { | |
drupal_add_js(path_to_theme() . '/js/vendor.js', $js_options); | |
drupal_add_js(path_to_theme() . '/js/script.js', $js_options); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment