Hi,
I want to add environment variables to my project, does anyone know how to do it?
I’ve read something about creating a configuration folder and using prod.json and dev.json files, but I didn’t get it. So if someone could be more precise and detailed in their solution, would be great.
The topic you shared has a solution provided by Erika. Did you try that solution and it didn’t work on your end? Or was something unclear in the solution she shared?
The solution was unclear to me. I tried to follow it, but there were some steps that I didn’t know how to solve them.
Following the example, do I have to add a configuration builder? it talks about PROD.ACCOUNT but how I have to name it in prod.json? is his name ACCOUNT or PROD.ACCOUNT and in dev.json, do I name it ACCOUNT or DEV.ACCOUNT
She says that:
if(production) {mivariable = PROD.ACCOUNT} else {mivariable=DEV.ACCOUNT }?
Hi @eduardo.luciano
What I’m struggling with is the relationship between config/prod.json or config/dev.json with react/theTsFileWhereIWantToAddTheEnv.ts. So how I connect this two files?
I know that I can import a json like any React project, but I expect something different, if not, I don’t understand the necessity of useRuntime for an .env question. useRuntime is only for the ability of changing environment variables from development or from production, but if you have constant environment variables, then is not necessary.
So to conclude, if you are telling me that vtex propose to substitute .env for .json, then I’ve been wasting my time searching for a solution that I knew at the begining. And also if you are telling me that vtex gives you the oportunity to change the jsonFile if I’m in production or development then… I knew that too.