Skip to content

Commit

Permalink
campaignion_vue: Don't add dependencies for apps that are bundled wit…
Browse files Browse the repository at this point in the history
…h them.
  • Loading branch information
mayakokits authored and torotil committed Mar 13, 2023
1 parent e9a0710 commit 697852a
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions campaignion_vue/campaignion_vue.module
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ function _campaignion_vue_filter_css($filename) {
}

// Add scripts, settings and styles needed by vue apps.
function _campaignion_vue_add_assets() {
function _campaignion_vue_add_assets($add_dependencies) {
$module_path = drupal_get_path('module', 'campaignion_vue');

// Add javascript.
drupal_add_js($module_path . '/js/campaignion_vue.min.js', [
'scope' => 'footer',
'group' => JS_LIBRARY,
'preprocess' => FALSE,
]);
if ($add_dependencies) {
drupal_add_js($module_path . '/js/campaignion_vue.min.js', [
'scope' => 'footer',
'group' => JS_LIBRARY,
'preprocess' => FALSE,
]);
}
drupal_add_js($module_path . '/js/interrupt-submit.js');

// Add element-ui locale.
Expand Down Expand Up @@ -58,13 +60,20 @@ function _campaignion_vue_get_strings($language = NULL) {
function campaignion_vue_preprocess_html(&$vars) {
$js = drupal_add_js();
$found = FALSE;
$add_dependencies = FALSE;
foreach ($js as $path => $options) {
if (substr($path, -11) == '.vue.min.js') {
if (substr($path, -24) == 'redirects_app.vue.min.js') {
// Add dependencies for the redirects_app only, the other apps are now
// bundled with their dependencies.
$add_dependencies = TRUE;
$found = TRUE;
break;
} elseif (substr($path, -11) == '.vue.min.js') {
$found = TRUE;
break;
}
}
if ($found) {
_campaignion_vue_add_assets();
_campaignion_vue_add_assets($add_dependencies);
}
}

0 comments on commit 697852a

Please sign in to comment.