High Score Labs News • Aug 26, 2021
- Package managers like Composer and NPM are used to import external dependencies.
Now, let’s cut to the chase.
Depending on your front-end tooling and workflow, there are a few different approaches to try on this one. Nevertheless, they all boil down to adding the dependencies you need to your package manager. If you’re using NPM, you can simply run the following code in the same location as your existing package.json file:
npm install inline-svg
The process is similar if you’re using Yarn, or another similar tool.
composer require oomphinc/composer-installers-extender
If your dependency is missing in Asset Packagist but has a repository that contains a composer.json file, load the VCS package repository using Composer instead.
If you’re publishing your custom module and utilizing it in several different projects, you can add your dependency to a composer.json file within the custom module rather than the root level composer.json file of each project.
If you’re using the custom module for a single project, however, you’ll need to manually add each custom module to the repositories section of the project’s root composer.json file.
Here are other methods to tackle the task:
- Add a CDN-contained externally-hosted version of the dependency as an external library in your module.
- If an externally-hosted version of the library isn’t available, download the dependency and package it with your module or theme.