Configuring react Official scaffolding server interface environment, different package name

Use react Official scaffolding, in development, will inevitably want to configure their own interface services environment, play a different package, as a front-end, it's all you want to automate manual and error-prone to change, and too much trouble, then record your own Configuring trip. . .

Reference react-create-app documentation

Compatible react IE 7 - 8 Low version

Concrete placement

... create a project .... 

Project structure

.Env also create a file in the root directory of the project, the default read (set a specific environment interface address)

.env.development, 设置开发环境接口地址

 .env.test,  设置测试环境接口地址

 .env.production   设置生产环境接口地址

.Env the beginning of the file again, you need to set the variable name, you must  REACT_APP_ work to begin with

Development Interface Configuration

Production Interface Configuration

Print Test 

And then add the following code to test index.js

console.log(process.env)

Start Service

Elevation start

Configure different packaging environments, refer to another article, a combination of both

Exposure profile

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Published 63 original articles · won praise 100 · views 310 000 +

Guess you like

Origin blog.csdn.net/qq_36407748/article/details/93485594