Feb 5, 2019
0
Level 4
Webpack Environment Variables
I am trying to access MIX_ENV_VAR for in my .js file with mix build, that's not happening.
// config.js
var uapi_base_url = 'http://localhost:8101/v1';
var capi_base_url = 'http://localhost:8102/v1';
// .env
MIX_ENV_VAR="http://localhost:8101/v1"
When doing console log in webpack.mix.js
// webpack.mix.js
console.log(process.env.MIX_ENV_VAR);
It returns correct stored value
mix.copy('resources/js/config.js', 'public/js/config.js');
But how can I make config.js uapi_base_url to use this env variable
Please or to participate in this conversation.