Finding light modules
Since all light modules are shared on npm, and include the keyword
magnolia-light-module, they are easy to find.
Because magnolia developers pay attention to good module design and readme files, its easy to quickly see if there is a module that matches your requirements.
Getting light modules
There are multiple ways to get the modules, we'll cover them in increasing sophistication.
The packages on npm are ready to use.
The simplest way to grab a package is to run
npm install <package name> in your terminal.
(A few warnings will be printed because npm expects a package.json in the directory where "npm install" is run.)
The light module is downloaded into the
node_modules directory. Move the light module into your Magnolia resources directory (aka
light-modules), and delete the
The npmjs.com search results also include links to the github repo (or other source control repository). So you can also clone or download the light module source with the information provided there.
Github contains the complete light module project. Check the readme, it may be necessary to build the project to get or build the required webresources. By convention - they can be built with
npm run build in the terminal.
The project can contain other useful files, like tests and demos - that you don't want to include in your production light module. Delete these files when you deploy the module to the Magnolia resources directory. (Typically the
node_modules directories. You can check the
.npmignore file for all things that do not belong in the 'built' light module.
Via an npm project
A benefit of having light modules on npm is that you can use its dependency resolution system to grab all the modules you need into your project.
This can be useful on a "light project", a Magnolia project based entirely on light modules. In the most basic version, you can define a package.json file which lists all of the light modules that you want. Anyone can then run
npm install to retrieve all of the modules.
Please see this section on light projects for more information and some example projects hosted on github.
For java deveopers, it's easy to retrieve light modules in your Maven based java projects via the maven-frontend-plugin.
This plugin enables configuring a complete, self contained, frontend build environment and specifying a package.json with the desired light modules as dependencies.
Some example pom.xml configuration: