From 2b176721e625a23cc75afbd59d1d0f60225efdef Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Wed, 20 May 2020 16:32:27 -0400 Subject: [PATCH 1/3] Fix dotenv file loading order --- docusaurus/docs/adding-custom-environment-variables.md | 4 ++-- packages/react-scripts/config/env.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docusaurus/docs/adding-custom-environment-variables.md b/docusaurus/docs/adding-custom-environment-variables.md index b604a10c810..48bfea2cf64 100644 --- a/docusaurus/docs/adding-custom-environment-variables.md +++ b/docusaurus/docs/adding-custom-environment-variables.md @@ -132,8 +132,8 @@ REACT_APP_NOT_SECRET_CODE=abcdef Files on the left have more priority than files on the right: -- `npm start`: `.env.development.local`, `.env.development`, `.env.local`, `.env` -- `npm run build`: `.env.production.local`, `.env.production`, `.env.local`, `.env` +- `npm start`: `.env.development.local`, `.env.local`, `.env.development`, `.env` +- `npm run build`: `.env.production.local`, `.env.local`, `.env.production`, `.env` - `npm test`: `.env.test.local`, `.env.test`, `.env` (note `.env.local` is missing) These variables will act as the defaults if the machine does not explicitly set them. diff --git a/packages/react-scripts/config/env.js b/packages/react-scripts/config/env.js index f4303bda95d..850b0cfa480 100644 --- a/packages/react-scripts/config/env.js +++ b/packages/react-scripts/config/env.js @@ -25,11 +25,11 @@ if (!NODE_ENV) { // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use const dotenvFiles = [ `${paths.dotenv}.${NODE_ENV}.local`, - `${paths.dotenv}.${NODE_ENV}`, // Don't include `.env.local` for `test` environment // since normally you expect tests to produce the same // results for everyone NODE_ENV !== 'test' && `${paths.dotenv}.local`, + `${paths.dotenv}.${NODE_ENV}`, paths.dotenv, ].filter(Boolean); From cbebd1082ac1fc7a553f37bf204f64b350efc21b Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Thu, 28 May 2020 11:46:23 +0300 Subject: [PATCH 2/3] tests: fix failing env tests --- .../fixtures/kitchensink/template/integration/env.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/fixtures/kitchensink/template/integration/env.test.js b/packages/react-scripts/fixtures/kitchensink/template/integration/env.test.js index 48a41d1fc81..fcff9a31d4b 100644 --- a/packages/react-scripts/fixtures/kitchensink/template/integration/env.test.js +++ b/packages/react-scripts/fixtures/kitchensink/template/integration/env.test.js @@ -38,7 +38,7 @@ describe('Integration', () => { 'development' ); expect(doc.getElementById('feature-file-env-x').textContent).toBe( - 'x-from-development-env' + 'x-from-original-local-env' ); } }); From 1e40cd225e6847ddb4a6876ae7c7ac2c3e381cbe Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Thu, 28 May 2020 11:56:04 +0300 Subject: [PATCH 3/3] tests: fix more failing tests --- .../fixtures/kitchensink/template/integration/env.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/fixtures/kitchensink/template/integration/env.test.js b/packages/react-scripts/fixtures/kitchensink/template/integration/env.test.js index fcff9a31d4b..0dd7c8fb359 100644 --- a/packages/react-scripts/fixtures/kitchensink/template/integration/env.test.js +++ b/packages/react-scripts/fixtures/kitchensink/template/integration/env.test.js @@ -31,7 +31,7 @@ describe('Integration', () => { 'production' ); expect(doc.getElementById('feature-file-env-x').textContent).toBe( - 'x-from-production-env' + 'x-from-original-local-env' ); } else { expect(doc.getElementById('feature-file-env').textContent).toBe(