MCPcopy Create free account
hub / github.com/bailicangdu/react-pxq / getClientEnvironment

Function getClientEnvironment

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

Source from the content-addressed store, hash-verified

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

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected