Light development is a modern front-end development approach that simplifies and speeds up development in Magnolia. A key feature is that configuration of common definitions, like dialogs and templates, moves out of JCR and onto the file system as YAML text files. As a developer you have all your code and configuration in the same place in files. This makes templates easier to understand, share, merge and manage in source control. Template scripts and configuration now live side-by-side in the same place.
Thanks to the new resource loading mechanism, Magnolia picks up any changes to the files right away without a restart, whether they reside on the Java classpath or file system. These simplifications accelerate project development in both Java Maven modules and the new light modules.
An additional benefit of the file system approach is that project teams or third party developers can easily create tools to generate Magnolia configuration.
Magnolia introduced light modules as part of the light development approach.
Develop Magnolia projects without Java skills
Now front-end developers can create Magnolia projects with light modules without the need for Java development skills, or even an SDK or Java IDE.
A light module is simply a directory on the file system that contains YAML definition files, FreeMarker template scripts, and other resource files of any type. The file system approach is more familiar to most front-end developers and this allows them to get up to speed fast in Magnolia. They can use all of their familiar tools, text editors, IDEs and build processes.
While light modules open Magnolia to front-end developers, Java is still the key to the deep integration and customisation capabilities of Magnolia.
Light modules and Maven modules
The light module approach aligns with traditional Java development: A project can be built with both Maven and light modules. Additionally, because the structure of light modules dovetails perfectly with Maven modules, a light module can easily be transformed into a Maven module by copying its contents into the Maven module. As a project architect, now you have the flexibility to build your project with the technologies that make the most sense for your project and team.
Light development capabilities
What can you do with light development now?
All of the following light development features are available in both Maven modules and light modules.
The following tasks are currently possible in light development:
- Modules: Create a module on the file system. See Creating a light module.
- Template prototype: Configure common things for all page templates. See Configuring a prototype in YAML.
- Template definitions: Write page, area and components definitions in YAML. See Template definition
- Template scripts: Write template scripts in FreeMarker and store them on the file system. See Template scripts.
- Dialog definitions: Write dialog definitions (templates and apps) in YAML and store them on the file system. See Dialog definition.
- Resource files: Store resource files on the file system. See resource origins and loading order.
- App definitions: Define content apps in YAML and store them on the file system. See Creating a custom content app.
- Include YAML files: Reuse a YAML definition in another definition using the include mechanism.
- Templating functions: Use templating functions instead of template models to define business logic in your scripts. See Templating functions.
- i18n: Store i18n properties files on the file system.
- Module dependencies: Manage module dependencies in a YAML-based module descriptor.
- Decorations: Reuse and modify existing configuration through decoration. (Since Magnolia 5.4.6)
Creating a website with Magnolia is a step-by-step guide in light development.
What is next for light development?
We are working on expanding light development functionality.
The following features are currently in development:
- Configure page template availability via YAML. MGNLSITE-45 - Getting issue details... STATUS
- Configure themes via YAML. MGNLSITE-48 - Getting issue details... STATUS
- Add Groovy template models to a light modules. MGNLSITE-45 - Getting issue details... STATUS
What is not supported in light modules?
- Site definition
- Module descriptor
- Register workspace
- Register nodetype
- Module class
- Module version handler
- Bootstrapping configuration via JCR
- Bootstrapping content
- Virtual URI mappings
Resource storage and loading in light development
The following example works equally well as a light module, or in the
src/main/resources directory of a Maven module.
Example: Light module structure.
Definitions in light development
Example: Simple page template definition.
Configuration of system parameters for light development
Set these properties in your
magnolia.properties file when developing light modules:
magnolia.developis a configuration property that can be set to
magnolia.propertiesfile for development purposes, specifically to:
- Enable ClasspathScanner when developing via IDE and changing or deploying edited classpath based resources.
- Disable the cache for resources.
- Disable the cache for FreeMarker template files. FreeMarker files are cached for 5 seconds when requested by default.
magnolia.resources.diris a property defining the directory from which resources are loaded in a Magnolia instance. This directory is used for file-based resources such as light modules and for overriding classpath resources. The property is configured in
WEB-INF/config/default/magnolia.propertiesand has the default value
$magnolia.home. To see the current value of the property, see the list of properties in the About Magnolia app Config Info tab.
magnolia.resources.watcher.sensitivityis a property that defines the sensitivity (speed) with which the changes of the resources in the
magnolia.resources.dirare observed by the DirectoryWatcherService. The property can be set in the
magnolia.propertiesconfiguration file to one of the following values:
high. If not set explicitly in the configuration file, the DirectoryWatcherService works by default under the
highvalue. For development purposes on OSX it is recommended to set the property to