Mantra how-to guide

Multiple mantraconfig files for the same project

How to easily configure differents versions of mantraconfig json file within the same project

05-Mar-2022
A  A  A 

As you know, any Mantra project is defined with a set of properties in the file mantraconfig.json file. These properties includes, between others:

  • Locations of the components.

  • Global vars

  • Data providers with their credential

  • etc.

Some of these configuration properties are environment dependent, this is, for development, surely you need differents data providers credentials (or differents providers), for production, static cache should be enabled, minify html, css or js files and the like. So, how to use differents mantraconfig.json files according to the environment where the project is being executed? With Linux symbolic links using the command "ln". Given two posible environments, lets say "dev" (for developing) and "prod" (for production), you can have those two files with their differents configurations:

  • dev.mantraconfig.json

  • prod.mantraconfig.json

And, finally, according with the environment machine, you need to create a symbolic link named "mantraconfig.json" pointing to one of them, like this:

$ ln mantraconfig.json dev.mantraconfig.json

And for production:

$ ln mantraconfig.json prod.mantraconfig.json

This gives you the flexibility needed to work with the project for differents deployment purposes (continuous integration, testing, experimental, etc.).