You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/react-cy-scripts/template/README.md
+12-12Lines changed: 12 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -442,14 +442,14 @@ Alternatively, you can force the linter to ignore any line by adding `// eslint-
442
442
443
443
Your project can consume variables declared in your environment as if they were declared locally in your JS files. By
444
444
default you will have `NODE_ENV` defined for you, and any other environment variables starting with
445
-
`REACT_APP_`.
445
+
`CY_APP_`.
446
446
447
447
**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.
448
448
449
-
>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). Changing any environment variables will require you to restart the development server if it is running.
449
+
>Note: You must create custom environment variables beginning with `CY_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). Changing any environment variables will require you to restart the development server if it is running.
450
450
451
451
These environment variables will be defined for you on `process.env`. For example, having an environment
452
-
variable named `REACT_APP_SECRET_CODE` will be exposed in your JS as `process.env.REACT_APP_SECRET_CODE`.
452
+
variable named `CY_APP_SECRET_CODE` will be exposed in your JS as `process.env.CY_APP_SECRET_CODE`.
453
453
454
454
There is also a special built-in environment variable called `NODE_ENV`. You can read it from `process.env.NODE_ENV`. When you run `npm start`, it is always equal to `'development'`, when you run `npm test` it is always equal to `'test'`, and when you run `npm run build` to make a production bundle, it is always equal to `'production'`. **You cannot override `NODE_ENV` manually.** This prevents developers from accidentally deploying a slow development build to production.
455
455
@@ -465,14 +465,14 @@ render() {
465
465
<div>
466
466
<small>You are running this application in<b>{process.env.NODE_ENV}</b> mode.</small>
During the build, `process.env.REACT_APP_SECRET_CODE` will be replaced with the current value of the `REACT_APP_SECRET_CODE` environment variable. Remember that the `NODE_ENV` variable will be set for you automatically.
475
+
During the build, `process.env.CY_APP_SECRET_CODE` will be replaced with the current value of the `CY_APP_SECRET_CODE` environment variable. Remember that the `NODE_ENV` variable will be set for you automatically.
476
476
477
477
When you load the app in the browser and inspect the `<input>`, you will see its value set to `abcdef`, and the bold text will show the environment provided when using `npm start`:
478
478
@@ -485,7 +485,7 @@ When you load the app in the browser and inspect the `<input>`, you will see its
485
485
</div>
486
486
```
487
487
488
-
The above form is looking for a variable called `REACT_APP_SECRET_CODE` from the environment. In order to consume this
488
+
The above form is looking for a variable called `CY_APP_SECRET_CODE` from the environment. In order to consume this
489
489
value, we need to have it defined in the environment. This can be done using two ways: either in your shell or in
490
490
a `.env` file. Both of these ways are described in the next few sections.
491
491
@@ -501,15 +501,15 @@ When you compile the app with `npm run build`, the minification step will strip
501
501
502
502
### Referencing Environment Variables in the HTML
503
503
504
-
You can also access the environment variables starting with `REACT_APP_` in the `public/index.html`. For example:
504
+
You can also access the environment variables starting with `CY_APP_` in the `public/index.html`. For example:
505
505
506
506
```html
507
-
<title>%REACT_APP_WEBSITE_NAME%</title>
507
+
<title>%CY_APP_WEBSITE_NAME%</title>
508
508
```
509
509
510
510
Note that the caveats from the above section apply:
511
511
512
-
* Apart from a few built-in variables (`NODE_ENV` and `PUBLIC_URL`), variable names must start with `REACT_APP_` to work.
512
+
* Apart from a few built-in variables (`NODE_ENV` and `PUBLIC_URL`), variable names must start with `CY_APP_` to work.
513
513
* The environment variables are injected at build time. If you need to inject them at runtime, [follow this approach instead](#generating-dynamic-meta-tags-on-the-server).
514
514
515
515
### Adding Temporary Environment Variables In Your Shell
@@ -520,15 +520,15 @@ life of the shell session.
520
520
#### Windows (cmd.exe)
521
521
522
522
```cmd
523
-
set REACT_APP_SECRET_CODE=abcdef&&npm start
523
+
set CY_APP_SECRET_CODE=abcdef&&npm start
524
524
```
525
525
526
526
(Note: the lack of whitespace is intentional.)
527
527
528
528
#### Linux, macOS (Bash)
529
529
530
530
```bash
531
-
REACT_APP_SECRET_CODE=abcdef npm start
531
+
CY_APP_SECRET_CODE=abcdef npm start
532
532
```
533
533
534
534
### Adding Development Environment Variables In `.env`
0 commit comments