0

[Solved]

Answer link in the comments

Current Architecture

So, I have a large scale vue project that serves multiple types of users from multiple subdomains. I maintain the project through netlify and point specific git branches to specific subdomains.

Let's call them Site One, Site Two and Site Three. I have three separate git branches to control them something like main, mini and micro branch.

Each subdomain/sites or branches has different features turned on or off depending on the targeted users.

I controlled them through a separate settings.json file until now. by branching off to different branches, I made separate commits to update the settings.json to achieve the behavior of each sites. (Don't think now it's a good idea though)

Here is a rough idea on how the settings.json looks like (which varies branch to branch):

{
  available_products: ['one', 'two', 'three'],
  feature_one_enabled: false,
  product_journey: 'ZIPPED'
  .....
  mini_mode: true,
}
// and many more flags;

Flaw

Here comes the pain point, when I find a bug that exists in all the branches and requires fixing in all of them, I can't just merge a branch into another because there were other changes targeted for the other branches.

Also the features incoming are most of the time unique and the current ones are periodically changing.

Question 1: is it a good practice to keep configuration flags to turn on or off the features in a .json file? Or should I go with .env files.

What now

So I have attempted with the fixing of the branch modeling and and keeping the codebase always unique, keeping checks for the configuration setting properties to enable features depending on the branch or the settings.json .env file.

Followed this branching model btw.

So, the branch and keeping the codebase identical in every branch is solved. Here comes the configurations thing. I can provide different .env values to netlify to control the features and all.

But when I am doing local development it will become a bit hassle because I have to set two .env file for each branch (total 6 for { n = 3 branches * 2 modes })

Question 2: how can I keep all the .env files locally and change them automatically through some npm command or branch changes ?

Or do I have to make some changes to the current architecture?

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.