Skip to main content
Home
Techies Briefcase
~ by Hari Venu

Main navigation

  • Home
  • About me
  • Photos
  • My Bookmarks

Breadcrumb

  1. Home
  2. How To Manage Front-end JavaScript Libraries With Composer In Drupal

How to manage front-end JavaScript libraries with composer in Drupal

By hari, 1 November, 2022

Drupal.org not officially providing a solution to add Front-end JavaScript libraries with composer command.

It's bit difficult to manage the front-end javascript libraries from NPM and Bower, but here is a way to manage that in composer.

Following command will help you to achieve this.


$ composer config repositories.asset-packagist composer https://asset-packagist.org

Once you execute the above command it will add https://asset-packagist.org as a repository in composer.json

This will update you composer.json file, and It's looks like below

Now, add the plugin as a dependency:


$ composer require oomphinc/composer-installers-extender

Then add installer type, just execute below command for that.


$ composer config --json --merge extra.installer-types '["bower-asset", "npm-asset"]'


$ composer config --json --merge 'extra.installer-paths.web/libraries/{$name}' '["type:bower-asset", "type:npm-asset"]'

composer.json will update like below

Finally you are done, now you can pull the libraries from Bower and NPM by composer command

Example


$ composer require npm-asset/dropzone

$ composer require bower-asset/dropzone

Reference
  • https://www.drupal.org/project/drupal/issues/3198245#comment-13997741
  • http://lightning.acquia.com/blog/round-your-front-end-javascript-libraries-composer

Tags

  • Drupal
  • Composer
  • NPM
  • Bower
 

Topics

  • Composer
  • Commad Line Tools
  • JavaScript
  • Drupal
  • Solar Panel
  • Permission
  • Libraries
  • MySQL
  • Commad Line
  • RSA
  • VSCode
  • Windows
  • Entity Query API
  • Ubuntu
  • Bash Script
  • Drush
  • Bower
  • Errors
  • Workflow
  • File API
  • Docker
  • Linux
  • Lando
  • Articles
  • Views
  • Nginx
  • Twig
  • Multilingual
  • OOPs
  • Coder
  • Solar Power
  • PHP
  • Field API
  • Android
  • Cache
  • Webform
  • jQuery
  • phpcbf
  • Ajax API
  • Distribution
  • Drupal Behavior
  • Learning
  • kali
  • professional development
  • Neuron AI
  • Jellyfin
  • SSH
  • URL
  • Macbook
  • WSL2
  • Drupal AI
  • NPM
  • Git
  • Form API
  • phpcs
  • Drupal Console
  • Codesniffer
  • Moderation
  • PHPSeclib
  • Taxonomy
  • Mac OS
RSS Feed

Who am I !!!

Hari Venu V
harivenu.v1992@gmail.com
Mobile : +91 9895164181
Whatsapp : +91 9895164181
Linkedin
Drupal.org
Github

Document
Resume.pdf (114.38 KB)

Work !!!

Fulltime Developer @ QED42
hari.venu@qed42.com
Linkedin

Powered by Drupal & Maintained by Hari