If I understand good enough we can set process.env.HOST trough dev.env.js.
~javascript
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
APP_NAME: '"some_name"',
HOST: '"0.0.0.0"'
})
~
So in config/index.js you colud do something like:
~javascript
host: process.env.HOST || 'localhost', // can be overwritten by process.env.HOST
~
But host is not changing to '0.0.0.0'. Extrange thing is that console logging process.env in config/index.js does not show HOST neither NODE_ENV.
I don麓t know if this is the correct way to set HOST environment variable through a configuration file or if this is an actual issue.
P.D: when I use this variables inside src files they work fine i.e.
~~~javascript
// src/main.js
if (process.env.APP_NAME === 'some_name') {
//do somethig
} else {
//do something else
}
~~~
No, you misunderstand. dev.env.js is only used to inject variables as "environment" variables into the app - they will not be accessible within the node process that runs webpack.
You should just set the host directly in config/index.js.
@LinusBorg how would it be the correct way to achive this? because in config/index.js there is a comment that says that host can be overwritten with process.env.HOST
That refers to an actual environment variable set when you run the dev server:
HOST=0.0.0.0 npm run dev
Or, to repeat myself, change it in config/index.js, you don't have to use an environment variable.
Alright then, thank you for your respond.
thank you
Most helpful comment
That refers to an actual environment variable set when you run the dev server: