mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-06-15 18:08:15 +08:00
Consistently set environment variables (#2382)
This commit is contained in:
committed by
William Monk
parent
9114aea7ac
commit
993fd306c5
1
packages/react-scripts/scripts/build.js
vendored
1
packages/react-scripts/scripts/build.js
vendored
@@ -11,6 +11,7 @@
|
||||
'use strict';
|
||||
|
||||
// Do this as the first thing so that any code reading it knows the right env.
|
||||
process.env.BABEL_ENV = 'production';
|
||||
process.env.NODE_ENV = 'production';
|
||||
|
||||
// Makes the script crash on unhandled rejections instead of silently
|
||||
|
||||
6
packages/react-scripts/scripts/start.js
vendored
6
packages/react-scripts/scripts/start.js
vendored
@@ -10,6 +10,10 @@
|
||||
// @remove-on-eject-end
|
||||
'use strict';
|
||||
|
||||
// Do this as the first thing so that any code reading it knows the right env.
|
||||
process.env.BABEL_ENV = 'development';
|
||||
process.env.NODE_ENV = 'development';
|
||||
|
||||
// Makes the script crash on unhandled rejections instead of silently
|
||||
// ignoring them. In the future, promise rejections that are not handled will
|
||||
// terminate the Node.js process with a non-zero exit code.
|
||||
@@ -17,8 +21,6 @@ process.on('unhandledRejection', err => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
process.env.NODE_ENV = 'development';
|
||||
|
||||
// Ensure environment variables are read.
|
||||
require('../config/env');
|
||||
|
||||
|
||||
2
packages/react-scripts/scripts/test.js
vendored
2
packages/react-scripts/scripts/test.js
vendored
@@ -10,6 +10,8 @@
|
||||
// @remove-on-eject-end
|
||||
'use strict';
|
||||
|
||||
// Do this as the first thing so that any code reading it knows the right env.
|
||||
process.env.BABEL_ENV = 'test';
|
||||
process.env.NODE_ENV = 'test';
|
||||
process.env.PUBLIC_URL = '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user