Drupal 8 Multiple Custom Modules Using Same External JS Lib (e.g. Angular)

I've been pulled onto a Drupal 8 project with multiple custom modules that need to use Angular.js. What is the best way to provide the Angular files to each module?

Right now, each module references the remote Angular files hosted by googleapis.com in my-module.libraries.yml.

my-module:   version: 1.x   js:     https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js: { type: external, minified: true }     https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular-sanitize.min.js { type: external, minified: true }     js/my-module.js: {preprocess: false}   dependencies:     - core/jquery     - core/jquery.ui     - core/jquery.ui.accordion 

However, I would prefer to host the Angular files locally and list them as dependencies just like jQuery.

I know I could put the Angular files in the module itself, but then each module would need its own copy.

Whatever is the proper way to do it, my goal is to host the Angular files locally and reference them from each module that depends on Angular.

Replay

Category: javascript Time: 2016-07-28 Views: 0
Tags: javascript

Related post

  • Multiple Custom Modules Using Same External JS Lib (e.g. Angular) 2016-07-28

    I've been pulled onto a Drupal 8 project with multiple custom modules that need to use Angular.js. What is the best way to provide the Angular files to each module? Right now, each module references the remote Angular files hosted by googleapis.com i

  • Record video clip from webcam in Drupal 7 custom module 2012-12-14

    I want to capture the video clip from webcam in my own Drupal 7 custom module. Is there any way to capture the webcam and record the video clips in Drupal 7? Please, anyone can help me on this? Thanks in advance. --------------Solutions-------------

  • Define multiple variables in a custom module using hook_variable_info() 2013-06-13

    Im using the Variable module and need to define a variable with the type "multiple" in my custom module. I've been googled whole my day searching for any documentation or just an example and haven't found anything. There are plenty examples how

  • How to send mail using drupal_mail function in drupal 6 custom module? 2013-11-12

    Am using drupal 6 site and building a custom module,have to send mail after form submission function mailform_mail($key, &$message, $params) { $headers = array( 'MIME-Version' => '1.0', 'Content-Type' => 'text/html; charset=UTF-8; format=flowed'

  • Page not found on new server in Drupal 7 custom module 2012-02-28

    I have a custom module that uses hook_menu() to create new routes. It works on all my existing Windows development boxes. I've recently set up an Ubuntu box, and installed Drupal; everything seems to work aside from the custom routes. I have a menu c

  • Drupal 7 custom module for menu 2012-03-27

    I am developing a custom module that will have the functionality to show a particular menu link active on the desired path. For this I have implemented hook_form_FROM_ID_alter() hook for menu_edit_item(). In the edit form of each menu item there I ha

  • Backup table from custom module using backup and migrate 2013-07-06

    I have a module that allows a user to add to a custom table in bulk via a custom form. But before they do so I'd like to backup that table to the private folder. Does anyone know if it is possible to create a new profile in the Backup and Migrate mod

  • Can I use same external drive to backup and install new version? 2014-05-01

    I have an old laptop with sadly out of date 10.04 Lucid on it. The internal drive is partitioned and contains Windows 7, which I never use. Gradually, it's losing functionality, as more software becomes incompatible with it. I recently bought an exte

  • multiple table sort using same function angularjs 2016-01-31

    I am a mediocre in Angularjs and need help on the same. I have two tables with the same headers and data in the table may or may not be different. I need to sort the data based on the click on header. I am using same sort function for both tables. Th

  • Multiple UITableViewCell subclasses using same xib? 2016-02-01

    How can I share one xib among multiple UITableViewCell subclasses? They all have the same view interface so I don't want to have to duplicate the same xib multiple times just to change the cell class. - (void)viewDidLoad { [super viewDidLoad]; [self.

  • Drupal 7 custom module menu hook is not working 2015-03-13

    I have created D7 module called 'mymodule' and enabled it from module list page. But the menu created inside the mymodule_menu() is not being called, instead redirects to 404 page. Below is the mymodule.info file name = my custom module description =

  • Create Multiple Custom Modules - Not Working 2015-10-27

    I have written this schema for creating 2 tables in my custom module.install <?php function my_registration_form_schema() { $schema = array(); $schema['myuser'] = array ( 'description' => t('The table containing users who have signed up for the chan

  • drupal variables custom module and views 2015-01-17

    I'm trying to figure out how Drupal works. I created a simple module named "myModule". In its myModule.module file I have: <?php function myModule_node_view($node, $view_mode, $langcode){ drupal_add_js(array('myModule' => array('nid' =>

  • Benefit of having multiple DH moduli of same length? 2015-12-07

    What is the benefit of having multiple Diffie Hellman moduli of the same length in OpenSSH's moduli file? In the distributed moduli file there are around 40 primes for each length to choose from randomly... In contrast, when using OpenSSL it seems to

  • How do I order by multiple custom fields using wp_query? 2011-04-07

    I have a rating system where the user can enter a custom field of either "Stars" or "Hearts", but whichever one they choose they have to enter a value of 1 thru 5. Using wp_query, I can successfully sort by one of these custom fields,

  • Put multiple custom loops on same page 2013-04-22

    I want multiple loops on my homepage, however only the first loop shows up. My homepage looks like this: <?php /* Template Name: Home */ get_header(); ?> <!--Four Columns--> <hr> <div id="content" class="twelve columns&

  • Multiple scripts run using same kernel 2014-03-31

    I have an external program that calls Mathematica scripts upon certain events. Each script requires a large Mathematica library to load (takes a while). Is there some way to run an initial script that loads the library, then each following script cal

  • Not able to override Community block file from another custom module within same codepool 2016-02-15

    I have an custom named "Abcmodule" within community folder within package name "Vss". Now I am developing an another module named "Xyzmodule" under same package same code pool i.e community. In Xyzmodule, I am overriding a bl

  • Multiple thunderbird users using same local directory 2014-03-05

    I have two users "tramp" and "office" on my desktop, and I want to run thunderbird from both users(I trust both users). I dont have enough disk space, so I want both the users to use the same local directory. Is this possible? I google

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 2.041 (s). 13 q(s)