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:
Ayrton De Craene
2016-09-23 12:59:38 +02:00
committed by Dan Abramov
parent 2050174631
commit 8e5183ac1b
6 changed files with 63 additions and 24 deletions

View File

@@ -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');

View File

@@ -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');

View File

@@ -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');