Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,25 @@ section of composer.json:
}
}
```

### How can I add js/css libraries using composer.json?

It is possible to use frontend libraries with composer thanks to the
asset-packagist repository (https://asset-packagist.org/).

For example, to use colorbox:
```
composer require npm-asset/colorbox:"^0.4"

```
Composer will detect new versions of the library that meet your constraints.
In the above example it will download anything from 0.4.* series of colorbox.

When managing libraries with composer this way, you may not want to add it to
version control. In that case, add specific directories to the .gitignore file.
```
# Specific libraries (which we manage with composer)
web/libraries/colorbox
```

For more details, see https://asset-packagist.org/site/about
13 changes: 12 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
"commerce_base": {
"type": "vcs",
"url": "https://github.com/drupalcommerce/commerce_base"
},
"asset-packagist": {
"type": "composer",
"url": "https://asset-packagist.org"
}
},
"config": {
Expand All @@ -36,6 +40,7 @@
"drupal/swiftmailer": "~1.0",
"drupal/token": "~1.0",
"drupalcommerce/commerce_base": "dev-8.x-1.x",
"oomphinc/composer-installers-extender": "^1.1",
"webflo/drupal-finder": "^1.0",
"webmozart/path-util": "^2.3"
},
Expand Down Expand Up @@ -74,12 +79,18 @@
]
},
"extra": {
"installer-types": [
"bower-asset",
"npm-asset"
],
"installer-paths": {
"web/core": [
"type:drupal-core"
],
"web/libraries/{$name}": [
"type:drupal-library"
"type:drupal-library",
"type:bower-asset",
"type:npm-asset"
],
"web/modules/contrib/{$name}": [
"type:drupal-module"
Expand Down