forked from a64f7bb4-7358-4778-9fbe-3b882c34cc1d/v1
75 lines
2.9 KiB
Markdown
75 lines
2.9 KiB
Markdown
|
|
***
|
|
## <a name="composer"></a>INSTALLING THIRD-PARTY LIBRARIES VIA COMPOSER
|
|
|
|
Until Drupal has an official [core management of the 3rd-party front-end libraries](https://www.drupal.org/project/drupal/issues/2873160), there are various ways to
|
|
install third party bower (deprecated)/ npm asset libraries.
|
|
|
|
Check out any below suitable to your workflow:
|
|
|
|
+ [#3021902](https://www.drupal.org/project/blazy/issues/3021902)
|
|
+ [#2907371](https://www.drupal.org/project/slick/issues/2907371)
|
|
+ [#2907371](https://www.drupal.org/project/slick/issues/2907371#comment-12882235)
|
|
+ Via [asset-packagist.org](https://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](https://asset-packagist.org/), regardless cons,
|
|
be sure to set up your composer.json correctly, some distros use it, see
|
|
[Slick](https://drupal.org/project/slick) project for the supporting distros to
|
|
copy/ paste from their composer.json files. Be warned! Invalid json may break.
|
|
Normally unwanted trailing commas.
|
|
|
|
1. Add/ merge these lines, add commas as required:
|
|
````
|
|
"repositories": [
|
|
{
|
|
"type": "composer",
|
|
"url": "https://asset-packagist.org"
|
|
}
|
|
]
|
|
````
|
|
|
|
2. 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"
|
|
],
|
|
// ....
|
|
}
|
|
}
|
|
````
|
|
|
|
3. Require [composer-installers-extender](https://github.com/oomphinc/composer-installers-extender):
|
|
`composer require oomphinc/composer-installers-extender`
|
|
|
|
4. Then require any libraries as usual only prefixed with `npm-asset`, or
|
|
`bower-asset` (deprecated). The versions must be re-checked, just samples:
|
|
+ Install [Blazy](https://www.drupal.org/project/blazy):
|
|
`composer require npm-asset/blazy:^1.8.2` <= not required at Blazy 2.6.
|
|
+ If using [Slick](https://www.drupal.org/project/slick), the namespace is
|
|
`slick-carousel`, not `slick`. The supported versions are `1.6.0 - 1.8.0`,
|
|
not `1.8.1` up, use exact numbers:
|
|
`composer require npm-asset/slick-carousel:1.8.0`
|
|
+ If using [Splide](https://www.drupal.org/project/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.
|
|
|
|
5. To update:
|
|
`composer update --with-dependencies`
|