2.9 KiB
INSTALLING THIRD-PARTY LIBRARIES VIA COMPOSER
Until Drupal has an official core management of the 3rd-party front-end libraries, there are various ways to install third party bower (deprecated)/ npm asset libraries.
Check out any below suitable to your workflow:
- #3021902
- #2907371
- #2907371
- Via asset-packagist.org, see below.
It is up to you to decide which works best. Composer is not designed to manage JS, CSS or HTML framework assets. It is for PHP. Then come Composer plugins, and other workarounds to make Composer workflow easier. As many alternatives, it is not covered here. Please find more info on the above-mentioned issues.
VIA ASSET-PACKAGIST.ORG
If using asset-packagist.org, regardless cons, be sure to set up your composer.json correctly, some distros use it, see Slick project for the supporting distros to copy/ paste from their composer.json files. Be warned! Invalid json may break. Normally unwanted trailing commas.
- Add/ merge these lines, add commas as required:
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
]
- Add/ merge these lines, add commas as required:
"extra": {
"installer-types": [
"bower-asset",
"npm-asset"
],
"installer-paths": {
"web/libraries/{$name}": [
"type:drupal-library",
"type:bower-asset",
"type:npm-asset"
],
// ....
}
}
-
Require composer-installers-extender:
composer require oomphinc/composer-installers-extender
-
Then require any libraries as usual only prefixed with
npm-asset
, orbower-asset
(deprecated). The versions must be re-checked, just samples:- Install Blazy:
composer require npm-asset/blazy:^1.8.2
<= not required at Blazy 2.6. - If using Slick, the namespace is
slick-carousel
, notslick
. The supported versions are1.6.0 - 1.8.0
, not1.8.1
up, use exact numbers:composer require npm-asset/slick-carousel:1.8.0
- If using Splide:
composer require npm-asset/splidejs--splide:^3
- If using Colorbox, verify the latest supported version:
composer require npm-asset/jquery-colorbox:^1.6.4
- etc.
- Install Blazy:
-
To update:
composer update --with-dependencies