This module uses fxp/composer-asset-plugin for integrating Bower and NPM packages support with Composer.
Since many Bower packages use LESS and SCSS preprocessors - oyejorge/less.php and leafo/scssphp are used to convert them into CSS.
To use this module you need to make few modifications in your component's meta.json:
There are two typical ways to use Bower and NPM dependencies (can be used simultaneously): AMD modules and explicit files inclusion
In case of AMD modules you just need to specify packages you want:
{
..
"require" : "composer_assets",
"require_bower" : {
"d3" : "3.5.14"
},
"require_npm" : {
"lodash" : "4.3.0"
},
..
}
And then you can load them when needed using RequireJS:
require(['lodash', 'd3'], function (_, d3) {
// do stuff
});
Another way is to list necessary files explicitly, so that they will be included on page automatically, for this purpose a bit more verbose syntax is used:
{
..
"require" : "composer_assets",
"require_bower" : {
"bootstrap" : {
"version" : "3.3.6",
"files" : [
"dist/css/bootstrap.css",
"dist/js/bootstrap.js"
]
}
},
..
}
No extra steps needed in this case.
If you have, let's say, d3 installed, then opening /bower_components/d3/d3.min.js
will also work and similarly for lodash /node_modules/lodash/dist/lodash.min.js
will be available.
It is not encouraged to use such paths directly, but might be useful in certain cases for cross-compatibility with third-party components.