Skip to content

Commit fd0b29c

Browse files
calwebrandycoulman
authored andcommitted
clarifying the use of custom environment variables (facebook#1513)
* clarifying the use of custom environment variables * Tweak
1 parent fbf7ac5 commit fd0b29c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

packages/react-scripts/template/README.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ Now you are ready to use the imported React Bootstrap components within your com
495495

496496
Flow is a static type checker that helps you write code with fewer bugs. Check out this [introduction to using static types in JavaScript](https://medium.com/@preethikasireddy/why-use-static-types-in-javascript-part-1-8382da1e0adb) if you are new to this concept.
497497

498-
Recent versions of [Flow](http://flowtype.org/) work with Create React App projects out of the box.
498+
Recent versions of [Flow](http://flowtype.org/) work with Create React App projects out of the box.
499499

500500
To add Flow to a Create React App project, follow these steps:
501501

@@ -515,7 +515,11 @@ To learn more about Flow, check out [its documentation](https://flowtype.org/).
515515
516516
Your project can consume variables declared in your environment as if they were declared locally in your JS files. By
517517
default you will have `NODE_ENV` defined for you, and any other environment variables starting with
518-
`REACT_APP_`. These environment variables will be defined for you on `process.env`. For example, having an environment
518+
`REACT_APP_`.
519+
520+
>Note: You must create custom environment variables beginning with `REACT_APP_`. Any other variables except `NODE_ENV` will be ignored to avoid accidentally [exposing a private key on the machine that could have the same name](https://github.com/facebookincubator/create-react-app/issues/865#issuecomment-252199527).
521+
522+
These environment variables will be defined for you on `process.env`. For example, having an environment
519523
variable named `REACT_APP_SECRET_CODE` will be exposed in your JS as `process.env.REACT_APP_SECRET_CODE`, in addition
520524
to `process.env.NODE_ENV`.
521525

@@ -623,12 +627,12 @@ These tutorials will help you to integrate your app with an API backend running
623627
using `fetch()` to access it.
624628

625629
### Node
626-
Check out [this tutorial](https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/).
630+
Check out [this tutorial](https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/).
627631
You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo).
628632

629633
### Ruby on Rails
630634

631-
Check out [this tutorial](https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/).
635+
Check out [this tutorial](https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/).
632636
You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo-rails).
633637

634638
## Proxying API Requests in Development
@@ -961,7 +965,7 @@ Snapshot testing is a feature of Jest that automatically generates text snapshot
961965

962966
### Editor Integration
963967

964-
If you use [Visual Studio Code](https://code.visualstudio.com), there is a [Jest extension](https://github.com/orta/vscode-jest) which works with Create React App out of the box. This provides a lot of IDE-like features while using a text editor: showing the status of a test run with potential fail messages inline, starting and stopping the watcher automatically, and offering one-click snapshot updates.
968+
If you use [Visual Studio Code](https://code.visualstudio.com), there is a [Jest extension](https://github.com/orta/vscode-jest) which works with Create React App out of the box. This provides a lot of IDE-like features while using a text editor: showing the status of a test run with potential fail messages inline, starting and stopping the watcher automatically, and offering one-click snapshot updates.
965969

966970
![VS Code Jest Preview](https://cloud.githubusercontent.com/assets/49038/20795349/a032308a-b7c8-11e6-9b34-7eeac781003f.png)
967971

@@ -1196,15 +1200,15 @@ GitHub Pages doesn't support routers that use the HTML5 `pushState` history API
11961200
### Heroku
11971201
11981202
Use the [Heroku Buildpack for Create React App](https://github.com/mars/create-react-app-buildpack).<br>
1199-
You can find instructions in [Deploying React with Zero Configuration](https://blog.heroku.com/deploying-react-with-zero-configuration).
1203+
You can find instructions in [Deploying React with Zero Configuration](https://blog.heroku.com/deploying-react-with-zero-configuration).
12001204
12011205
#### Resolving "Module not found: Error: Cannot resolve 'file' or 'directory'"
12021206
12031207
Sometimes `npm run build` works locally but fails during deploy via Heroku with an error like this:
12041208
12051209
```
12061210
remote: Failed to create a production build. Reason:
1207-
remote: Module not found: Error: Cannot resolve 'file' or 'directory'
1211+
remote: Module not found: Error: Cannot resolve 'file' or 'directory'
12081212
MyDirectory in /tmp/build_1234/src
12091213
```
12101214

0 commit comments

Comments
 (0)