File shadowing
Build projects on top of projects
Last updated
Was this helpful?
Build projects on top of projects
Last updated
Was this helpful?
Mosaic introduces the concept of shadowing (overriding) files. Shadowing is a feature of .
The shadowing mechanism will only function for files in the src
and public
directories your theme, parent theme or extensions.
Create a child theme, set the mosaic.parentTheme
value of its package.json to the proper parent theme. This parent theme should be into your child theme.
Determine the file of the parent theme you are willing to shadow.
Create a file on the same path of the child theme.
functions/classes/variables which are going to be provided to the application instead of the initial ones. You may or may not use the original functionality within these values.
that all of the exports of the parent theme are also exported from this file.
In case the package.json
fieldmosaic.parentTheme
is empty, your theme is considered to be a root theme. In this case, parent theme overrides will not function, as there is simply no parent theme.
Work with a theme, in which some extension is installed
Determine the file of the extension you are willing to shadow.
Create a file on the path of the child theme that is build as follows: src/<module name>/<relative path>
where <relative path> is relative to the extension's src
directory
functions/classes/variables which are going to be provided to the application instead of the initial ones. You may or may not use the original functionality within these values.
that all of the exports of the parent theme are also exported from this file.
If the file you created will unintentionally match extension's or parent theme's path, it will override it. Be careful not to break the functionality, while creating new files and folders.
Mosaic implements following sequence of override preference (from highest priority to lowest):
Your theme's files
Parent theme's files
Extensions files
An extension cannot override another extension's file