【问题标题】:Routing based on different environments with React RouterReact Router 基于不同环境的路由
【发布时间】:2018-03-16 17:44:47
【问题描述】:

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

【问题讨论】:

  • create-react-app 允许你创建环境变量,查看它的文档
  • 你尝试了什么?

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


【解决方案1】:
"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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-03
    • 2017-07-17
    • 2016-07-01
    • 1970-01-01
    • 2021-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多