-
-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(env): Load env from
.env.[browser]
variants (#1078)
Co-authored-by: Aaron <[email protected]>
- Loading branch information
1 parent
d06f812
commit c031c6e
Showing
3 changed files
with
19 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
import { config } from 'dotenv'; | ||
import type { TargetBrowser } from '../../types'; | ||
|
||
/** | ||
* Load environment files based on the current mode. | ||
* Load environment files based on the current mode and browser. | ||
*/ | ||
export function loadEnv(mode: string) { | ||
export function loadEnv(mode: string, browser: TargetBrowser) { | ||
return config({ | ||
path: [`.env.${mode}.local`, `.env.${mode}`, `.env.local`, `.env`], | ||
// Files on top override files below | ||
path: [ | ||
`.env.${mode}.${browser}.local`, | ||
`.env.${mode}.${browser}`, | ||
`.env.${browser}.local`, | ||
`.env.${browser}`, | ||
`.env.${mode}.local`, | ||
`.env.${mode}`, | ||
`.env.local`, | ||
`.env`, | ||
], | ||
}); | ||
} |