diff --git a/packages/react-scripts/config/env.js b/packages/react-scripts/config/env.js
index 3f417304833..9fe2cf2d551 100644
--- a/packages/react-scripts/config/env.js
+++ b/packages/react-scripts/config/env.js
@@ -15,7 +15,7 @@
var REACT_APP = /^REACT_APP_/i;
function getClientEnvironment(publicUrl) {
- var processEnv = Object
+ var vars = Object
.keys(process.env)
.filter(key => REACT_APP.test(key))
.reduce((env, key) => {
@@ -31,15 +31,18 @@ function getClientEnvironment(publicUrl) {
// images into the `src` and `import` them in code to get their paths.
'PUBLIC_URL': publicUrl
});
-
- processEnv['process.env'] = Object
- .keys(processEnv)
+ // Stringify all values so we can feed into Webpack DefinePlugin
+ var string = Object
+ .keys(vars)
.reduce((env, key) => {
- env[key] = JSON.stringify(processEnv[key]);
+ env[key] = JSON.stringify(vars[key]);
return env;
}, {});
- return processEnv;
+ return {
+ vars: vars,
+ string: string,
+ };
}
module.exports = getClientEnvironment;
diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js
index 969cfb0eb61..7f3b26202e8 100644
--- a/packages/react-scripts/config/webpack.config.dev.js
+++ b/packages/react-scripts/config/webpack.config.dev.js
@@ -202,10 +202,11 @@ module.exports = {
];
},
plugins: [
- // Makes the public URL available as %PUBLIC_URL% in index.html, e.g.:
+ // Makes some environment variables available in index.html.
+ // The public URL is available as %PUBLIC_URL% in index.html, e.g.:
//
// In development, this will be an empty string.
- new InterpolateHtmlPlugin(env),
+ new InterpolateHtmlPlugin(env.vars),
// Generates an `index.html` file with the