MCPcopy Create free account
hub / github.com/remy/jsconsole / getClientEnvironment

Function getClientEnvironment

config/env.js:60–88  ·  view source on GitHub ↗
(publicUrl)

Source from the content-addressed store, hash-verified

58const REACT_APP = /^REACT_APP_/i;
59
60function getClientEnvironment(publicUrl) {
61 const raw = Object.keys(process.env)
62 .filter(key => REACT_APP.test(key))
63 .reduce(
64 (env, key) => {
65 env[key] = process.env[key];
66 return env;
67 },
68 {
69 // Useful for determining whether we’re running in production mode.
70 // Most importantly, it switches React into the correct mode.
71 NODE_ENV: process.env.NODE_ENV || 'development',
72 // Useful for resolving the correct path to static assets in `public`.
73 // For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
74 // This should only be used as an escape hatch. Normally you would put
75 // images into the `src` and `import` them in code to get their paths.
76 PUBLIC_URL: publicUrl,
77 }
78 );
79 // Stringify all values so we can feed into Webpack DefinePlugin
80 const stringified = {
81 'process.env': Object.keys(raw).reduce((env, key) => {
82 env[key] = JSON.stringify(raw[key]);
83 return env;
84 }, {}),
85 };
86
87 return { raw, stringified };
88}
89
90module.exports = getClientEnvironment;

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected