Подключение библиотек для модуля Webform с использованием composer

Автор: Aussie, 5 июля, 2022
How to use composer to install libraries for the Webform module Last updated on 1 July 2021 For anybody facing the question of what is the best-recommended method for installing/updating/managing all libraries required by the Webform module, the answer is to install libraries using composer! The Webform module comes shipped with a "composer.libraries.json" file contains information about all up-to-date libraries required by the module itself, and so we will be using this file to install all libraries by merging the "composer.libraries.json" with the "composer.json" file of our Drupal website. 1) The merging is accomplished by the aid of the Composer Merge Plugin plugin available on GitHub, so from the project directory, open a terminal and run: composer require wikimedia/composer-merge-plugin 2) Edit the "composer.json" file of your website and under the "extra": { section add: * note: the `web` represents the folder where drupal lives like: ex. `docroot`. "merge-plugin": { "include": [ "web/modules/contrib/webform/composer.libraries.json" ] }, From now on, every time the "composer.json" file is updated, it will also read the content of "composer.libraries.json" file located at web/modules/contrib/webform/ and update accordingly. 3) In order for the "composer.json" file to install all the libraries mentioned as a CDN inside the "composer.libraries.json", from a terminal, run composer update --lock or composer update if lock option doesn't work. This method will assure that all the libraries will be served from CDN and automatically updated once the "composer.libraries.json" is updated with new versions of the Webform module. 4) If you want to install all the mentioned libraries in a local directory on your webserver, typically web/libraries, then you need to run composer update --with-dependencies This method will ensure that composer will pull the libraries from the CDN source and store a copy in your libraries directory in your Drupal installation. https://www.drupal.org/node/3003140