-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
babel-plugin-transform-inline-environment-variables does not seem to work with react-native #687
Comments
Same here, the only property in process.env is NODE_ENV and it can't be modified. |
Will have a look. Can give you the version number of the plugin? |
Can you provide more info - sample code, expected output, actual output, babel config ? |
Using I have these npm scripts:
But both Logging out process.env shows it only has |
but only works with |
Modify your
Also add |
Sometimes it can work, but sometimes it can't |
you may need to clear the cache |
I recently made this work and commented on another issue. Here is the link |
I'm facing the same issue https://github.com/riwu/synergy-lab-time-estimation/blob/3a68af7e5cd1c5f4f19a9f389e634ec4a8305fea/client/src/actions/api.js#L4 It works for Android, and iOS built for Debug, but not iOS built for Release. |
this happens to me too. react native .54 babel-plugin-transform-inline 0.3.0. Please fix! The environment variable just gets cached somewhere and won't change even if I change it |
Doesn't work. v0.4.0, using react-native-scripts |
You can demonstrate the issue pretty easily here: https://github.com/skyl/react-native-zcash/tree/babel-minify-687 Checkout that branch, and run:
Run the app on an emulator (for instance, hitting |
I've added this package to my dependencies and added to .babelrc plugins. I can log the value but there are two problems:
|
Clearing the cache with |
still not working. somebody help |
Any workarounds for this? It's causing code to run which causes an error because the |
Any status about the issue? I have the same issue. My project is by nuxtjs. |
Any status about the issue? |
still not working. somebody help |
Still having this issue :/ |
It does work, but as mentioned above: you probably have to clear the babel cache.
then stop that, then start Babel sees that the source code is the same, so it uses the cached version. It doesn't know that the env vars changed (which would result in a different compiled output). |
I was in group in which things don't work out of the box. After struggling some time I can share how I make it works.
Important to note. We have to define all variables in include array. |
@GrzegorzStanczyk This solution worked for me 🎉 |
It's also probably worth noting that Didn't work for me🚫 const {
API_URL,
SOME_KEY
} = process.env Worked for me ✅ const API_URL = process.env.API_URL
const SOME_KEY = process.env.SOME_KEY |
Apparently the only way this works is clearing the cache. |
downgrade from version 4.x.x to 0.3.0 works with me. |
stupid problem. I defined 2 script in package.json look like this
, but only works. After figured out a whole day, i found that the issue is the space and the tab between REACT_NATIVE_A=X and react-native start. Tab works but space don't. Hope this help |
be careful the space or tab between VARIABLE_NAME and react-native start. tab work but space don't |
Was logging process.env wondering why it wasn't popping up, but logging the value directly does.
In my code, I logged the following:
A little frustrating that the log couldn't show what I was looking for but very cool when you get it going. One last thing for anyone curious, This is the .babelrc file I made to make this work:
on React Native 0.57.8, React 16.6.3 shoutout to @reyraa for the idea to check |
Solved the problem by following the documentation My .babelrc file
|
I was not able to use The I could come up with a solution doing the following:
Follow example below: require('dotenv/config')
export default {
name: 'your-app-name',
displayName: 'your-app-name',
version: '1.0.0',
expo: {
name: 'your-app-name',
slug: 'your-app-name',
version: '1.0.0',
assetBundlePatterns: [
'**/*',
],
extra: {
// Here you can declare your variables getting the value from .env file
EXAMPLE: process.env.EXAMPLE,
},
},
}
Extra thanks to @martins20 who worked with me on this solution. |
You're welcome bro |
Okay so no one is caring to fix it thats bad |
As the title says, babel-plugin-transform-inline-environment-variables doesn't seem to work with react-native. I'm not sure if it is supposed to work? My react-native version is: 0.48.2
The process.env.somevar is undefined. Do I need to clear some babel cache or something to get this working?
The text was updated successfully, but these errors were encountered: