2

We have a xxx.json which describes which data access layer our app has to use:

{
  "service_base": "https://xxxx.com",
  "resource_base": "/build/resources",
  "template_base": "build/templates/dir"
}

The Gulp build will use this file to build the application. Now we are using different dal's so we want to use an environment variable to pass with the gulp build command. How do we have to obtain this?

I read it's not possible to declare env vars in JSON. We tried something as this but didn't work:

{
  "service_base": process.env.DAL_ENV,
  "resource_base": "/build/resources",
  "template_base": "build/templates/dir"
}

And trying to pass the env var DAL_ENV to our gulp build command.

Yan Foto
  • 10,850
  • 6
  • 57
  • 88
DenCowboy
  • 13,884
  • 38
  • 114
  • 210
  • Already answered: http://stackoverflow.com/questions/28787457/how-can-i-set-an-environment-variable-from-gulp – Mohamed Labouardy Jul 18 '16 at 08:17
  • Not really the same as my question I think – DenCowboy Jul 18 '16 at 14:09
  • you can't do anything programmatically inside a json file. You can however *not* use a json file, or alter the data you get from it before you use it. Why not just read the env var from within gulpfile? – Kevin B Jul 18 '16 at 15:12

0 Answers0