Skip to content

Commit 318b251

Browse files
weitzmanbojanz
authored andcommitted
Add asset-packagist repository and config. (#21)
1 parent 7f050ec commit 318b251

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,25 @@ section of composer.json:
114114
}
115115
}
116116
```
117+
118+
### How can I add js/css libraries using composer.json?
119+
120+
It is possible to use frontend libraries with composer thanks to the
121+
asset-packagist repository (https://asset-packagist.org/).
122+
123+
For example, to use colorbox:
124+
```
125+
composer require npm-asset/colorbox:"^0.4"
126+
127+
```
128+
Composer will detect new versions of the library that meet your constraints.
129+
In the above example it will download anything from 0.4.* series of colorbox.
130+
131+
When managing libraries with composer this way, you may not want to add it to
132+
version control. In that case, add specific directories to the .gitignore file.
133+
```
134+
# Specific libraries (which we manage with composer)
135+
web/libraries/colorbox
136+
```
137+
138+
For more details, see https://asset-packagist.org/site/about

composer.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
"commerce_base": {
1818
"type": "vcs",
1919
"url": "https://github.com/drupalcommerce/commerce_base"
20+
},
21+
"asset-packagist": {
22+
"type": "composer",
23+
"url": "https://asset-packagist.org"
2024
}
2125
},
2226
"config": {
@@ -36,6 +40,7 @@
3640
"drupal/swiftmailer": "~1.0",
3741
"drupal/token": "~1.0",
3842
"drupalcommerce/commerce_base": "dev-8.x-1.x",
43+
"oomphinc/composer-installers-extender": "^1.1",
3944
"webflo/drupal-finder": "^1.0",
4045
"webmozart/path-util": "^2.3"
4146
},
@@ -74,12 +79,18 @@
7479
]
7580
},
7681
"extra": {
82+
"installer-types": [
83+
"bower-asset",
84+
"npm-asset"
85+
],
7786
"installer-paths": {
7887
"web/core": [
7988
"type:drupal-core"
8089
],
8190
"web/libraries/{$name}": [
82-
"type:drupal-library"
91+
"type:drupal-library",
92+
"type:bower-asset",
93+
"type:npm-asset"
8394
],
8495
"web/modules/contrib/{$name}": [
8596
"type:drupal-module"

0 commit comments

Comments
 (0)