使用React Router基于不同环境进行路由

时间:2018-03-16 17:44:48

标签: javascript reactjs react-router react-redux react-router-v4

我使用create-react-app开发了react redux应用程序。现在我想在不同的环境中部署它,比如我的本地,即localhost / abc,一些UAT,即https://10.123.123/abc等,以及Production,https://someUrl/abc。如何使用不同的环境配置制作基本URL,如本地,UAT,Prod等。

1 个答案:

答案 0 :(得分:0)

"scripts": {
  "build": "sh -ac '. .env.${REACT_APP_ENV}; react-scripts build'",
  "build:staging": "REACT_APP_ENV=staging npm run build",
  "build:production": "REACT_APP_ENV=production npm run build",
  ...
}

$ npm run build:staging

看看这个!

https://medium.com/@tacomanator/environments-with-create-react-app-7b645312c09d