Skip to content

Instantly share code, notes, and snippets.

@robdecker
Last active November 11, 2020 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robdecker/7258774 to your computer and use it in GitHub Desktop.
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
<?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;
}
}
<?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