Open zzc-tongji opened 6 years ago
This functionality is handled by the React Native Bundler (Metro) and out of the scope of React 360.
How are you using this environment variable? If you're toggling behavior, it might be easier to pass a variable at initialization time.
If you're hoping to completely eliminate some code in production, the React Native bundler isn't set up to do full dead code elimination. It does handle one case, __DEV__
, which is true in development builds and false in release builds. The bundler will completely eliminate statements like if (__DEV__)
in release builds. This may be what you're looking for.
Didn't get how to pass the config variables to worker thread in react 360.
I got it.
There is no way to parse any environment variables to index.vr.js
, since index.vr.js
is running in a "visual machine" (independent space, more exactly) in browser.
One solution (perhaps not so good) is to create a file environment.js
and import it to index.vr.js
. Change it before running or bundling to parse something outside.
How to get
WEBVR_ENV
when I useWEBVR_ENV=test node node_modules/react-native/local-cli/cli.js start
to run the project?I have tried to use
process.env.WEBVR_ENV
, but it isundefined
.console.log(process.env.WEBVR_ENV)
shows{NODE_ENV: "development"}
.