-
Notifications
You must be signed in to change notification settings - Fork 653
Can't get runtime env variables anymore on Create-React-App 2.0 #131
Comments
Hi @arik-gamerlink, create-react-app v2 upgrades to webpack v4, which is probably the cause of this breakage. We’ll need to investigate where the js-runtime module is now bundled, figure out which Thanks for reporting! It will probably take me a week to get to this. I’ll add notice to the README shortly. |
Thanks for the response! I look forward to seeing the new release. Let me know if you need any more information from me. |
It looks like the new builds generate (at least) 2 js files:
with the |
Given that the bundle is programmatically split, it doesn’t seem we can predict which file might contain the js-runtime-env module. Perhaps the best permanent solution is to match/glob the |
sounds good to me, at least for now. though maybe someone that knows more about webpack 4 can chime in. |
Just released v7.0.0, which fixes this issue. create-react-app 2 split bundles are now supported for runtime env vars. |
Hi,
I've recently been using this buildpack. I took note that runtime env variables wouldn't be possible without the "@mars/heroku-js-runtime-env" dependecy. So I installed it and wrote something like;
import runtimeEnv from '@mars/heroku-js-runtime-env'; const env = runtimeEnv(); export const serverUrl = env.REACT_APP_BACKEND_API || 'https://backend-staging.herokuapp.com/';
It worked great for a while, and now I seem to be getting an error;
I believe this happened right after upgrading to create-react-app 2.0
The text was updated successfully, but these errors were encountered: