I have an ejected project and I build my web with expo tools.
I want to have a JS file in a static directory that has replaced env variables. I already tried this:
Steps that I expected it to work:
- Add babel variable substitution plugin (from URL)
- Include the variable into the babel substitution plugin as it’s done in the expo tutorial from the URL
- Add a reference to env variable into the JS file. I used this content and none of these were substituted:
%REACT_APP_API_HOST% process.env.REACT_APP_API_HOST REACT_APP_API_HOST
I’d like to know a good way to handle this.
Alternatively I consider fetching the data inside that JS file from back-end or generating that JS file using a template (during the build step).
I’d prefer to not involve back-end in this and I’d also prefer that this templating work would be done by env library and not by me.
This is what I’ll use in my build step for now:
yarn run babel --plugins "react-native-dotenv,transform-inline-environment-variables" web-pre-babel/hi.js