Several different production environment variables

We’ve developed a SPA for service communication which should be used for the companies different brands. The application is exact the same for all brands, there is only a difference during build (changing colors, titles etc).

To achieve the different builds we’re using environment variables. The applications are also deployed under different domains, so i need three projects in Netlify which source is always the same Git.

Is there a possibility to do something like this in a netlify.toml file, but specifiy the project there the production variables for?

# Brand 1
[context.production.environment]
  FRONTEND_ENVIRONMENT = "foo"
  BRAND_ID = "2"
  SITE_TITLE = "Foo Service App"

# Brand 2
[context.production.environment]
  FRONTEND_ENVIRONMENT = "asdf"
  BRAND_ID = "2"
  SITE_TITLE = "Asdf Service App"

I know that there is the possibility to add environments variables in the Netlify backend for each project, but i would like to have these settings in our version control.

Thanks in advance!

All the best,
Marvin

Another possibility might be if i could create different netlify.toml files and then say in the ui of the project which config file to use. Is there such a possibility?

Just to clarify, you are reusing the same code across multiple SPAs and selecting styles based on environment variables?

Do you have the ability to structure your repo such that you have a master code base and deploy a support branch for each site?

I understand it may not be as convenient as shoving it all in .toml but it does offer separation between your clients and room for flexibility/specialization in the future. just merge master to each branch every time you update it. To me, this seems a better practice despite being less convenient.
Just my opinion, though it’s certainly not without its own flaws.

Just to clarify, you are reusing the same code across multiple SPAs and selecting styles based on environment variables?

Yes. It’s 100% the same SPA with the same functionality, because it’s for one customer, he just has different brands.

And then THEME = foo then i inject assets/scss/theme/foo/_settings.scss at build time and change some colors.

Besides there are other settings like API_KEY but in the end there are only 5 variables.

Do you have the ability to structure your repo such that you have a master code base and deploy a support branch for each site?

Not really, it would made it far more complex.

We’ve currently using Gitlab CI, but I would like to have all the great feature and simplicity Netlify offers.

Hi @marvinhuebner,

There isn’t a simple solution, it sounds like you somehow want to link different netlify.toml to diff Netlify sites, which you can’t do. The Netlify.toml has to be there at the beginning of the build, and the usual solution would be to generate a _headers or _redirects file during the build. The suggestion I have for you is to use different variable names for different sites and then use logic in your build process or site that pics different environment variables based on the site. You’ll know which site a build is running in because we inject that information in environment variables automatically.