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