sha*_*oof 5 plugins babeljs react-native
module.exports = function () {
return {
"presets": ['module:metro-react-native-babel-preset'],
"plugins": [
["transform-inline-environment-variables", {
"include": [
"APP_ENV"
]
}]
]
}
};
Run Code Online (Sandbox Code Playgroud)
这是我的react-native项目的babel.config.js,我正在尝试配置transform-inline-environment-variables babel插件。但每当我运行应用程序时,环境变量总是未定义。
我运行react-native start --reset-cache以清除缓存并使用命令运行项目APP_ENV=dev react-native run-ios。
但该变量仍然未定义。我在这里做错了什么?React-native版本是0.60.6
尝试直接记录访问(而不是解构):
console.log(process.env.APP_ENV)
Run Code Online (Sandbox Code Playgroud)
另外,一旦连接了模拟器,您就可以运行,start因此:
yarn run-iosAPI_ENV=dev yarn start --reset-cache此处详细介绍了这个问题。
更好的是,用react-native-config替换你的实现。
| 归档时间: |
|
| 查看次数: |
6268 次 |
| 最近记录: |