File tree Expand file tree Collapse file tree 3 files changed +16
-14
lines changed
packages/react-scripts/config Expand file tree Collapse file tree 3 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -19,21 +19,27 @@ function getClientEnvironment(publicUrl) {
19
19
. keys ( process . env )
20
20
. filter ( key => REACT_APP . test ( key ) )
21
21
. reduce ( ( env , key ) => {
22
- env [ key ] = JSON . stringify ( process . env [ key ] ) ;
22
+ env [ key ] = process . env [ key ] ;
23
23
return env ;
24
24
} , {
25
25
// Useful for determining whether we’re running in production mode.
26
26
// Most importantly, it switches React into the correct mode.
27
- 'NODE_ENV' : JSON . stringify (
28
- process . env . NODE_ENV || 'development'
29
- ) ,
27
+ 'NODE_ENV' : process . env . NODE_ENV || 'development' ,
30
28
// Useful for resolving the correct path to static assets in `public`.
31
29
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
32
30
// This should only be used as an escape hatch. Normally you would put
33
31
// images into the `src` and `import` them in code to get their paths.
34
- 'PUBLIC_URL' : JSON . stringify ( publicUrl )
32
+ 'PUBLIC_URL' : publicUrl
35
33
} ) ;
36
- return { 'process.env' : processEnv } ;
34
+
35
+ processEnv [ 'process.env' ] = Object
36
+ . keys ( processEnv )
37
+ . reduce ( ( env , key ) => {
38
+ env [ key ] = JSON . stringify ( processEnv [ key ] ) ;
39
+ return env ;
40
+ } , { } ) ;
41
+
42
+ return processEnv ;
37
43
}
38
44
39
45
module . exports = getClientEnvironment ;
Original file line number Diff line number Diff line change @@ -205,17 +205,15 @@ module.exports = {
205
205
// Makes the public URL available as %PUBLIC_URL% in index.html, e.g.:
206
206
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
207
207
// In development, this will be an empty string.
208
- new InterpolateHtmlPlugin ( {
209
- PUBLIC_URL : publicUrl
210
- } ) ,
208
+ new InterpolateHtmlPlugin ( env ) ,
211
209
// Generates an `index.html` file with the <script> injected.
212
210
new HtmlWebpackPlugin ( {
213
211
inject : true ,
214
212
template : paths . appHtml ,
215
213
} ) ,
216
214
// Makes some environment variables available to the JS code, for example:
217
215
// if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`.
218
- new webpack . DefinePlugin ( env ) ,
216
+ new webpack . DefinePlugin ( env [ 'process.env' ] ) ,
219
217
// This is necessary to emit hot updates (currently CSS only):
220
218
new webpack . HotModuleReplacementPlugin ( ) ,
221
219
// Watcher doesn't work well if you mistype casing in a path so we use
Original file line number Diff line number Diff line change @@ -218,9 +218,7 @@ module.exports = {
218
218
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
219
219
// In production, it will be an empty string unless you specify "homepage"
220
220
// in `package.json`, in which case it will be the pathname of that URL.
221
- new InterpolateHtmlPlugin ( {
222
- PUBLIC_URL : publicUrl
223
- } ) ,
221
+ new InterpolateHtmlPlugin ( env ) ,
224
222
// Generates an `index.html` file with the <script> injected.
225
223
new HtmlWebpackPlugin ( {
226
224
inject : true ,
@@ -242,7 +240,7 @@ module.exports = {
242
240
// if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
243
241
// It is absolutely essential that NODE_ENV was set to production here.
244
242
// Otherwise React will be compiled in the very slow development mode.
245
- new webpack . DefinePlugin ( env ) ,
243
+ new webpack . DefinePlugin ( env [ 'process.env' ] ) ,
246
244
// This helps ensure the builds are consistent if source hasn't changed:
247
245
new webpack . optimize . OccurrenceOrderPlugin ( ) ,
248
246
// Try to dedupe duplicated modules, if any:
You can’t perform that action at this time.
0 commit comments