Composer Patches & Libraries Installation
Composer Patches¶
Enable Patching¶
- Require
cweagans/composer-patches
. - Add patch related parts to the
extra
section ofcomposer.json
. - Add a patch to
patches
section of theextra
section ofcomposer.json
. - Run
composer install
"extra": {
"enable-patching": true,
"composer-exit-on-patch-failure": true,
"patchLevel": {
"drupal/core": "-p2"
},
"patches": {
"drupal/bootstrap_sass": {
"Errors on running npm install in subtheme on Node 16+ (https://www.drupal.org/project/bootstrap_sass/issues/3259490)": "https://git.drupalcode.org/project/bootstrap_sass/-/merge_requests/5.diff"
}
},
"drupal-scaffold": {
"locations": {
"web-root": "web/"
}
},
Installation of Libraries¶
Installation of Drupal Libraries¶
Define packages as needed in repositories
section of composer.json
. See example below.
{
"type": "package",
"package": {
"name": "dinbror/blazy",
"version": "1.8.2",
"type": "drupal-library",
"dist": {
"url": "https://github.com/dinbror/blazy/archive/1.8.2.zip",
"type": "zip"
},
"require": {
"composer/installers": "^1.2.0"
}
}
},
{
"type": "package",
"package": {
"name": "kenwheeler/slick",
"version": "1.8.0",
"type": "drupal-library",
"dist": {
"url": "https://github.com/kenwheeler/slick/archive/v1.8.0.zip",
"type": "zip"
},
"require": {
"composer/installers": "^1.2.0"
}
}
},
Then require the packages.
Some libraries can be checked in Status Report - /admin/reports/status via Drupal UI.
CK Editor Plugins¶
Install extender via composer.
Define custom installer type and installer path.
"extra": {
"installer-types": ["ckeditor-plugin"],
"installer-paths": {
"web/libraries/ckeditor/plugins/{$name}": ["type:ckeditor-plugin"],
}
}
Define package.
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
},
{
"type": "package",
"package": {
"name": "ckeditor-plugin/templates",
"version": "4.19.0",
"type": "ckeditor-plugin",
"dist": {
"url": "https://download.ckeditor.com/templates/releases/templates_4.19.0.zip",
"type": "zip"
}
}
}
],
Install defined package via composer.
Alternatively while defining package type drupal-library
can be used which does not require extender, custom installer type and installer path.
Reference: Managing CKEditor plugins using composer