forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.ts
More file actions
23 lines (21 loc) · 887 Bytes
/
env.ts
File metadata and controls
23 lines (21 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
// injected into the application via DefinePlugin in Webpack configuration.
import getHost from '../utils/host';
const REACT_APP = /^REACT_APP_/i;
const NODE_ENV = JSON.stringify(process.env.NODE_ENV || 'development');
const LOCAL_SERVER = Boolean(JSON.stringify(process.env.LOCAL_SERVER));
export default Object.keys(process.env)
.filter(key => REACT_APP.test(key))
.reduce(
(env, key) => {
env['process.env.' + key] = JSON.stringify(process.env[key]);
return env;
},
{
'process.env.NODE_ENV': NODE_ENV,
'process.env.CODESANDBOX_HOST': JSON.stringify(getHost()),
'process.env.LOCAL_SERVER': Boolean(LOCAL_SERVER),
'process.env.STAGING': 'STAGING_BRANCH' in process.env,
'process.env.VSCODE': Boolean(JSON.stringify(process.env.VSCODE)),
}
);