-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如何和react-native-config一起使用 #5
Comments
可以准备两个文件,比如 |
正常来讲都是在 {
"scripts": {
"start": "cp -f .env.local .env && react-native start",
"deploy": "cp -f .env.prod .env && upload-pgy"
}
} |
在新版的react-native中,不再建议使用react-native-config,你可以直接在代码中使用node.js的语法 if (process.env.NODE_ENV === 'development') {
// Do something
} else {
// Do something
} 旧版本的RN可以使用transform-inline-environment-variables达到同样的效果 |
但是,我的项目可能需要打包不止两个环境,比如说有开发环境,多个测试环境,以及正式环境。还有就是有一些涉及原生的,比如说极光推送的app_key的配置之类的 |
之前是怎么处理的呢? |
我是创建多个命令来打包的,这是我以前的项目的package.json里的scripts |
根据shell的特性,您可以做适当的更改达到同样的效果 {
"scripts": {
"deploy:test": "export ENVFILE=.env.test && upload-pgy",
"deploy:production": "export ENVFILE=.env.production && upload-pgy"
}
} 在scripts中定义的脚本会使用新的进程处理,使用export只影响新的进程和其子进程而不影响当前终端(父进程),与 |
我以为export 只能放在cd android 之后。 |
我的项目中使用react-native-config,编译时需要指定一个配置文件。不知道该如何使用?
The text was updated successfully, but these errors were encountered: