Closed kylehuynh205 closed 2 years ago
For JS library required by Drupal module, for example: PDF module needs pdf.js library to be cloned and place under libraries directory (ie. drupal/web/libraries). To have it run automatically with composer, place the following code in composer.json
at root of Drupal site (for site level),
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
},
{
"type": "package",
"package": {
"name": "mozilla/pdf.js",
"version": "2.10.377",
"type":"drupal-library",
"source": {
"url": "https://github.com/mozilla/pdf.js.git",
"type": "git",
"reference": "master"
}
}
}
],
"require": {
"mozilla/pdf.js": "2.10.377"
},
Make sure to have:
require
section:"composer/installers": "^1.0"
installer-paths
section: "installer-paths": {
"web/core": ["type:drupal-core"],
"web/libraries/{$name}": ["type:drupal-library"],
"web/modules/contrib/{$name}": ["type:drupal-module"],
"web/profiles/contrib/{$name}": ["type:drupal-profile"],
"web/themes/contrib/{$name}": ["type:drupal-theme"],
"drush/Commands/{$name}": ["type:drupal-drush"]
},
Clone the repository with a zip file instead:
{
"name":"smarty/smarty",
"version":"3.1.7",
"dist":{
"url":"https://www.smarty.net/files/Smarty-3.1.7.zip",
"type":"zip"
}
}
In composer.json of a Drupal module, make sure to have:
Because by default, composer is looking for package in packagist.org, but Drupal has their own place for its modules and themes, the code block above redirected to Drupal's package site.
Next, include all the dependencies in the
"require"
block, ie.Implemented: