mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-05-24 05:47:38 +08:00
Load environment file in development (#695)
* Load environment file via dotenv if .env file is present * Document loading environment variables in .env file * Minor doc tweaks
This commit is contained in:
committed by
Dan Abramov
parent
2050174631
commit
8e5183ac1b
6
packages/react-scripts/scripts/build.js
vendored
6
packages/react-scripts/scripts/build.js
vendored
@@ -12,6 +12,12 @@
|
||||
// Do this as the first thing so that any code reading it knows the right env.
|
||||
process.env.NODE_ENV = 'production';
|
||||
|
||||
// Load environment variables from .env file. Surpress warnings using silent
|
||||
// if this file is missing. dotenv will never modify any environment variables
|
||||
// that have already been set.
|
||||
// https://github.com/motdotla/dotenv
|
||||
require('dotenv').config({silent: true});
|
||||
|
||||
var chalk = require('chalk');
|
||||
var fs = require('fs-extra');
|
||||
var path = require('path');
|
||||
|
||||
6
packages/react-scripts/scripts/start.js
vendored
6
packages/react-scripts/scripts/start.js
vendored
@@ -11,6 +11,12 @@
|
||||
|
||||
process.env.NODE_ENV = 'development';
|
||||
|
||||
// Load environment variables from .env file. Surpress warnings using silent
|
||||
// if this file is missing. dotenv will never modify any environment variables
|
||||
// that have already been set.
|
||||
// https://github.com/motdotla/dotenv
|
||||
require('dotenv').config({silent: true});
|
||||
|
||||
var path = require('path');
|
||||
var chalk = require('chalk');
|
||||
var webpack = require('webpack');
|
||||
|
||||
6
packages/react-scripts/scripts/test.js
vendored
6
packages/react-scripts/scripts/test.js
vendored
@@ -10,6 +10,12 @@
|
||||
process.env.NODE_ENV = 'test';
|
||||
process.env.PUBLIC_URL = '';
|
||||
|
||||
// Load environment variables from .env file. Surpress warnings using silent
|
||||
// if this file is missing. dotenv will never modify any environment variables
|
||||
// that have already been set.
|
||||
// https://github.com/motdotla/dotenv
|
||||
require('dotenv').config({silent: true});
|
||||
|
||||
const createJestConfig = require('./utils/createJestConfig');
|
||||
const jest = require('jest');
|
||||
const path = require('path');
|
||||
|
||||
Reference in New Issue
Block a user