ui/config.yaml
A SOMOD module can define a set of configurations in the config.yaml
file.
The SOMOD build command validates ui/config.yaml
and generates /build/ui/config.json
. The SOMOD prepare command combines config.json from all dependency modules to create .env
and next.config.js
.
Most of the configuration in config.yaml
refers to the SOMOD parameter for their values. The parameter values from parameters.json
are applied to generate .env
and next.config.js
while preparing.
The config.yaml
contains four sections. All four sections are optional.
env
This section defines the environmental variables required by the module. SOMOD generates .env
from this section.
env: NEXT_PUBLIC_MY_API_URL: # any SOMOD common keywords SOMOD::Parameter: mycomponent.api.url MY_API_TOKEN: SOMOD::If: - # this is true - # use this value - # else this
The env is a map of the Environmental variable to the Common Keywords.
imageDomains
When a module uses an external image, the external domain name needs to be configured in imageDomains. Read more about image optimization in NextJs documentation.
imageDomains: - example.com - SOMOD::Parameter: mycomponent.image.cdn
The imageDomains is an array of hardcoded domain name strings or Common Keywords.
publicRuntimeConfig
This section is similar to the publicRuntimeConfig of NextJs configuration. The SOMOD's publicRuntimeConfig refers to the SOMOD parameter for the value.
publicRuntimeConfig: myTheme: # any SOMOD common keywords SOMOD::Parameter: mycomponent.api.url apiUrl: # any SOMOD common keywords
The publicRuntimeConfig is a map of the config name to the Common Keywords.
serverRuntimeConfig
The serverRuntimeConfig is similar to publicRuntimeConfig, but these configs are available only on the server.
serverRuntimeConfig: apiToken: # any SOMOD common keywords SOMOD::Parameter: mycomponent.api.url
The serverRuntimeConfig is a map of the config name to the Common Keywords.
In the Next Chapter, let us understand how SOMOD processes ui/config.yaml
and serverless/template.yaml
files.
Write an email to opensource@sodaru.com