From cbdb63b5600a40676e65416e57c8a94ef59c5d6d Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 23 Feb 2017 16:57:29 +0200 Subject: [PATCH] add a comment about NODE_ENV value set to 'production' during build step https://github.com/facebookincubator/create-react-app/issues/790#issuecomment-281986264 --- packages/react-scripts/template/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index f44cd23dd59..124100b3a90 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -604,6 +604,7 @@ default you will have `NODE_ENV` defined for you, and any other environment vari **The environment variables are embedded during the build time**. Since Create React App produces a static HTML/CSS/JS bundle, it can’t possibly read them at runtime. To read them at runtime, you would need to load HTML into memory on the server and replace placeholders in runtime, just like [described here](#injecting-data-from-the-server-into-the-page). Alternatively you can rebuild the app on the server anytime you change them. >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). +> Also note that during build for deployment (`npm run build`), `NODE_ENV` will be hard-set to `'production'`. These environment variables will be defined for you on `process.env`. For example, having an environment variable named `REACT_APP_SECRET_CODE` will be exposed in your JS as `process.env.REACT_APP_SECRET_CODE`, in addition