Skip to content

Commit ebfb627

Browse files
committed
update README
1 parent 155f0b5 commit ebfb627

File tree

1 file changed

+24
-37
lines changed

1 file changed

+24
-37
lines changed

README.md

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -533,23 +533,21 @@ Override any environment variables that have already been set.
533533

534534
## FAQ
535535

536-
<details>
537-
<summary>What about variable expansion?</summary>
536+
<details><summary>What about variable expansion?</summary><br/>
538537

539538
Try [dotenv-expand](https://github.com/motdotla/dotenv-expand)
540-
</details>
541539

542-
<details>
543-
<summary>Should I commit my `.env` file?</summary>
540+
</details>
541+
<details><summary>Should I commit my `.env` file?</summary><br/>
544542

545543
No. We **strongly** recommend against committing your `.env` file to version
544+
546545
control. It should only include environment-specific values such as database
547546
passwords or API keys. Your production database should have a different
548547
password than your development database.
549-
</details>
550548

551-
<details>
552-
<summary>How do I use dotenv with `import`?</summary>
549+
</details>
550+
<details><summary>How do I use dotenv with `import`?</summary><br/>
553551

554552
Simply..
555553

@@ -606,18 +604,15 @@ There are two alternatives to this approach:
606604
2. Create a separate file that will execute `config` first as outlined in [this comment on #133](https://github.com/motdotla/dotenv/issues/133#issuecomment-255298822)
607605
</details>
608606

609-
<details>
610-
<summary>Should I have multiple `.env` files?</summary>
607+
<details><summary>Should I have multiple `.env` files?</summary><br/>
611608

612609
We recommend creating one `.env` file per environment. Use `.env` for local/development, `.env.production` for production and so on. This still follows the twelve factor principles as each is attributed individually to its own environment. Avoid custom set ups that work in inheritance somehow (`.env.production` inherits values form `.env` for example). It is better to duplicate values if necessary across each `.env.environment` file.
613610

614611
> In a twelve-factor app, env vars are granular controls, each fully orthogonal to other env vars. They are never grouped together as “environments”, but instead are independently managed for each deploy. This is a model that scales up smoothly as the app naturally expands into more deploys over its lifetime.
615612
>
616613
> [The Twelve-Factor App](http://12factor.net/config)
617614
</details>
618-
619-
<details>
620-
<summary>Can I customize/write plugins for dotenv?</summary>
615+
<details><summary>Can I customize/write plugins for dotenv?</summary><br/>
621616
622617
Yes! `dotenv.config()` returns an object representing the parsed `.env` file. This gives you everything you need to continue setting values on `process.env`. For example:
623618

@@ -628,9 +623,7 @@ const myEnv = dotenv.config()
628623
variableExpansion(myEnv)
629624
```
630625
</details>
631-
632-
<details>
633-
<summary>What rules does the parsing engine follow?</summary>
626+
<details><summary>What rules does the parsing engine follow?</summary><br/>
634627

635628
The parsing engine currently supports the following rules:
636629

@@ -651,27 +644,24 @@ line'}
651644
```
652645

653646
- backticks are supported (`` BACKTICK_KEY=`This has 'single' and "double" quotes inside of it.` ``)
654-
</details>
655647

656-
<details>
657-
<summary>What about syncing and securing .env files?</summary>
648+
</details>
649+
<details><summary>What about syncing and securing .env files?</summary><br/>
658650

659651
Use [dotenvx](https://github.com/dotenvx/dotenvx) to unlock syncing encrypted .env files over git.
660-
</details>
661652

662-
<details>
663-
<summary>What if I accidentally commit my `.env` file to code?</summary>
653+
</details>
654+
<details><summary>What if I accidentally commit my `.env` file to code?</summary><br/>
664655

665656
Remove it, [remove git history](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository) and then install the [git pre-commit hook](https://github.com/dotenvx/dotenvx#pre-commit) to prevent this from ever happening again.
666657

667658
```
668659
brew install dotenvx/brew/dotenvx
669660
dotenvx precommit --install
670661
```
671-
</details>
672662

673-
<details>
674-
<summary>What happens to environment variables that were already set?</summary>
663+
</details>
664+
<details><summary>What happens to environment variables that were already set?</summary><br/>
675665

676666
By default, we will never modify any environment variables that have already been set. In particular, if there is a variable in your `.env` file which collides with one that already exists in your environment, then that variable will be skipped.
677667

@@ -680,10 +670,9 @@ If instead, you want to override `process.env` use the `override` option.
680670
```javascript
681671
require('dotenv').config({ override: true })
682672
```
683-
</details>
684673

685-
<details>
686-
<summary>How can I prevent committing my `.env` file to a Docker build?</summary>
674+
</details>
675+
<details><summary>How can I prevent committing my `.env` file to a Docker build?</summary><br/>
687676

688677
Use the [docker prebuild hook](https://dotenvx.com/docs/features/prebuild).
689678

@@ -695,20 +684,18 @@ RUN curl -fsS https://dotenvx.sh/ | sh
695684
RUN dotenvx prebuild
696685
CMD ["dotenvx", "run", "--", "node", "index.js"]
697686
```
698-
</details>
699687

700-
<details>
701-
<summary>How come my environment variables are not showing up for React?</summary>
688+
</details>
689+
<details><summary>How come my environment variables are not showing up for React?</summary><br/>
702690

703691
Your React code is run in Webpack, where the `fs` module or even the `process` global itself are not accessible out-of-the-box. `process.env` can only be injected through Webpack configuration.
704692

705693
If you are using [`react-scripts`](https://www.npmjs.com/package/react-scripts), which is distributed through [`create-react-app`](https://create-react-app.dev/), it has dotenv built in but with a quirk. Preface your environment variables with `REACT_APP_`. See [this stack overflow](https://stackoverflow.com/questions/42182577/is-it-possible-to-use-dotenv-in-a-react-project) for more details.
706694

707695
If you are using other frameworks (e.g. Next.js, Gatsby...), you need to consult their documentation for how to inject environment variables into the client.
708-
</details>
709696

710-
<details>
711-
<summary>Why is the `.env` file not loading my environment variables successfully?</summary>
697+
</details>
698+
<details><summary>Why is the `.env` file not loading my environment variables successfully?</summary><br/>
712699

713700
Most likely your `.env` file is not in the correct place. [See this stack overflow](https://stackoverflow.com/questions/42335016/dotenv-file-is-not-loading-environment-variables).
714701

@@ -719,10 +706,9 @@ require('dotenv').config({ debug: true })
719706
```
720707

721708
You will receive a helpful error outputted to your console.
722-
</details>
723709

724-
<details>
725-
<summary>Why am I getting the error `Module not found: Error: Can't resolve 'crypto|os|path'`?</summary>
710+
</details>
711+
<details><summary>Why am I getting the error `Module not found: Error: Can't resolve 'crypto|os|path'`?</summary><br/>
726712

727713
You are using dotenv on the front-end and have not included a polyfill. Webpack < 5 used to include these for you. Do the following:
728714

@@ -759,6 +745,7 @@ module.exports = {
759745
```
760746

761747
Alternatively, just use [dotenv-webpack](https://github.com/mrsteele/dotenv-webpack) which does this and more behind the scenes for you.
748+
762749
</details>
763750

764751
## Contributing Guide

0 commit comments

Comments
 (0)