How to use the server's system environment variables in configuration files such as vue,webpack project, prod.env.js under config, etc.

what is written in the configuration file directly is the private network url, but now you want to use the environment variables configured on the server instead. How to modify it

module.exports = {

NODE_ENV: ""production"",
ENV_CONFIG: ""prod"",
BASE_API: ""http://192.168.xx.xx:8088""

}

for example, I have two environments,

one set of development tests, one set of production,

I can write

directly in the configuration file.

BASE_API:url

then deploy to the development test server 192.168.1.1, where the server configuration environment variable url is 192.168.1.2

deploy to open production server 192.168.2.1 the server configuration environment variable url is 192.168.2.2

so I don"t need to change the code, and I don"t need to hit the package twice

http://www.jb51.net/article/1. I"ve seen this solution, but if I had 100 environments, wouldn"t I have to write 100 3-item operations

Mar.01,2021

shouldn't you pack it locally and throw it on the server?

Menu