Skip to content

Commit 096f3c6

Browse files
author
Archie Lee
committed
Changed variables naming to raw and stringified
1 parent 0e5fcdc commit 096f3c6

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

packages/react-scripts/config/env.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
var REACT_APP = /^REACT_APP_/i;
1616

1717
function getClientEnvironment(publicUrl) {
18-
var vars = Object
18+
var raw = Object
1919
.keys(process.env)
2020
.filter(key => REACT_APP.test(key))
2121
.reduce((env, key) => {
@@ -32,18 +32,18 @@ function getClientEnvironment(publicUrl) {
3232
'PUBLIC_URL': publicUrl
3333
});
3434
// Stringify all values so we can feed into Webpack DefinePlugin
35-
var string = {
35+
var stringified = {
3636
'process.env': Object
37-
.keys(vars)
37+
.keys(raw)
3838
.reduce((env, key) => {
39-
env[key] = JSON.stringify(vars[key]);
39+
env[key] = JSON.stringify(raw[key]);
4040
return env;
4141
}, {}),
4242
};
4343

4444
return {
45-
vars: vars,
46-
string: string,
45+
raw: raw,
46+
stringified: stringified,
4747
};
4848
}
4949

packages/react-scripts/config/webpack.config.dev.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,15 @@ module.exports = {
206206
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
207207
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
208208
// In development, this will be an empty string.
209-
new InterpolateHtmlPlugin(env.vars),
209+
new InterpolateHtmlPlugin(env.raw),
210210
// Generates an `index.html` file with the <script> injected.
211211
new HtmlWebpackPlugin({
212212
inject: true,
213213
template: paths.appHtml,
214214
}),
215215
// Makes some environment variables available to the JS code, for example:
216216
// if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`.
217-
new webpack.DefinePlugin(env.string),
217+
new webpack.DefinePlugin(env.stringified),
218218
// This is necessary to emit hot updates (currently CSS only):
219219
new webpack.HotModuleReplacementPlugin(),
220220
// Watcher doesn't work well if you mistype casing in a path so we use

packages/react-scripts/config/webpack.config.prod.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ var env = getClientEnvironment(publicUrl);
5454

5555
// Assert this just to be safe.
5656
// Development builds of React are slow and not intended for production.
57-
if (env.string['process.env'].NODE_ENV !== '"production"') {
57+
if (env.stringified['process.env'].NODE_ENV !== '"production"') {
5858
throw new Error('Production builds must have NODE_ENV=production.');
5959
}
6060

@@ -219,7 +219,7 @@ module.exports = {
219219
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
220220
// In production, it will be an empty string unless you specify "homepage"
221221
// in `package.json`, in which case it will be the pathname of that URL.
222-
new InterpolateHtmlPlugin(env.vars),
222+
new InterpolateHtmlPlugin(env.raw),
223223
// Generates an `index.html` file with the <script> injected.
224224
new HtmlWebpackPlugin({
225225
inject: true,
@@ -241,7 +241,7 @@ module.exports = {
241241
// if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
242242
// It is absolutely essential that NODE_ENV was set to production here.
243243
// Otherwise React will be compiled in the very slow development mode.
244-
new webpack.DefinePlugin(env.string),
244+
new webpack.DefinePlugin(env.stringified),
245245
// This helps ensure the builds are consistent if source hasn't changed:
246246
new webpack.optimize.OccurrenceOrderPlugin(),
247247
// Try to dedupe duplicated modules, if any:

0 commit comments

Comments
 (0)