Friday 26 April 2019

Is it possible to import a JSON file based on the path in the .env?

I'm using ES6 modules and I'm loading the data like this:import data from './somefolder/config';This works, but when I try to do something like this:import data from `${process.env.JSON_PATH}`Naturally, this doesn't work at all. Are there any workarounds here?Basically I have two config.json files, one for development and one for production and I'd like to load it based on this. Sure, I could check if the .env is production or not and based on that load the data, but I wanted to make it more config-oriented.Any ideas?

Submitted April 26, 2019 at 05:38PM by JavascriptFanboy

No comments:

Post a Comment