【问题标题】:React-Native: Using different config.json for dev and prodReact-Native:对 dev 和 prod 使用不同的 config.json
【发布时间】:2019-04-05 11:52:37
【问题描述】:

我有一个 React-Native 项目,我正在我的“staging”服务器上进行测试。现在是时候在“production”服务器上发布它了。

我正在使用 config.json 文件,其中包含服务器信息,例如 api 密钥、api 地址等。

我想要的是为“生产”和“暂存”使用不同的 config.json。当我使用生产 config.json 时,我的包中不会有暂存 config.json 的痕迹。

src
- config
-- config.js
-- production-server.json
-- staging-server.json

可能类似于:yarn build-staging、yarn build-production

【问题讨论】:

  • 你确定你有 react-native 的问题吗? react-native 是关于移动开发的!不是关于服务器;-)
  • 是的。移动应用程序连接到 api 服务器对吗?对于暂存和生产,此服务器是不同的。

标签: react-native


【解决方案1】:

你试过 react-native-config 吗?它允许为不同的环境设置不同的配置文件。更多详情可以看这篇文章Link

【讨论】:

    猜你喜欢
    • 2021-01-04
    • 1970-01-01
    • 1970-01-01
    • 2011-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-18
    • 1970-01-01
    相关资源
    最近更新 更多