Hoppa till huvudinnehåll
Menu

Adding a external JavaScript library to composer

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

The module 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.drupal.org/8"
    },
    {
        "type": "package",
        "package": {
            "name": "desandro/masonry",
            "version": "master",
            "type": "drupal-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:drupal-library"
],
...

So to install the library, you just need to run


composer require desandro/masonry

Vi hjälper dig nå resultat. Kontakta oss Ring direkt på 08-20 90 04.

Stockholms Stadsmission väljer Drupal

Vi har fått förtroendet att hjälpa till med övergripande koncept, design och kontinuerlig utveckling av Stockholms Stadsmiss…
MDN

Cache in Drupal 8: How it worked, and what we wanted to be solved in D8

If you just want your content to be cached before Drupal 8, there were almost no problems, just turn on caching for anonymou…
MDN

Cache in Drupal 8: Introduction

In a series of blog posts we will go through how caching works in Drupal 8, to try to demystify the caching layer in Drupal …
MDN

Updating taxonomy term name in Drupal 8

Here you can read how to use hook update for updating taxonomy terms in Drupal 8.