(publicUrl)
| 58 | const REACT_APP = /^REACT_APP_/i; |
| 59 | |
| 60 | function 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 | |
| 90 | module.exports = getClientEnvironment; |
no outgoing calls
no test coverage detected