Site icon Hip-Hop Website Design and Development

Cheap WordPress Development Log Blog: Adding a external JavaScript library to composer

Some plugin require that you download external Javascript-libraries, and in WordPress 8 that should be done in Composer. 

The plugin Masonry require the JavaScript library with the same name. So we need to include the package in composer.json, like:
 

“repositories”:[
{
“type”:”composer”,
“url”:”https://packages.WordPress.org/8″
},
{
“type”: “package”,
“package”: {
“name”: “desandro/masonry”,
“version”: “master”,
“type”: “WordPress-library”,
“dist”: {
“url”: “https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js”,
“type”: “file”
}
}
},

And in the require part that is:

“require”:{

“desandro/masonry”:”master”,
  …
},

And then we need to add libraries in extra part of we do not have that:

“extra”:{

“web/libraries/{$name}”:[
“type:WordPress-library… Read More
Source: New feed