I am using the pattern to store config variables in my /config/[xxx].env.js files like so:
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
API: {
ROOT: "'http://blah.blah.blah'"
},
CONNECTORS: {
SPOTIFY: {
CLIENT_ID: "'blah'",
SCOPES: "'blah'",
REDIRECT_URI: "'blah'"
}
}
})
Note that some of these aren't specifically environment variables, but I want to put these type of config vars in a centralized location.
In my main.js, I can access the variables fine via process.env:
Vue.http.options.root = process.env.API.ROOT
But in a lower level component, "process" does not exist.
I'm aware that it shouldn't, since its not globally defined, but I cannot figure out how to get to that process.env object from within a component. I know I can make it global, but that doesn't "feel right."
Two questions:
Is there some other Vue import / object that I'm missing to get to process.env?
Is there a better way to store these type of centralized values, that might be environment dependent? I've seen things like the ruby config gem that does a nice job of layering environment specific configs on top of default configs.
I did try the npm config gem, but for some reason it is missing other required npms, and appears to be geared toward node.js, AND it feels like I'm doing something wrong not using what vue-cli webpack provides.