Skip to content

Commit 997c1d0

Browse files
authored
feat(env-vars): add support for basic environment variables (#84)
* feat(env-vars): add support for basic environment variables * [cleanup]
1 parent 5dac8aa commit 997c1d0

File tree

9 files changed

+324
-218
lines changed

9 files changed

+324
-218
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ yarn-error.log
44
stats.json
55
coverage
66
storybook-static
7+
.DS_Store
8+
.idea
9+
.env

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Install development/build dependencies
2121
Start the development server
2222
`npm run start:dev`
2323

24-
Run a production build
24+
Run a production build (outputs to "dist" dir)
2525
`npm run build`
2626

2727
Run the test suite
@@ -39,6 +39,12 @@ Launch a tool to inspect the bundle size
3939
Start the express server (run a production build first)
4040
`npm run start`
4141

42+
Start storybook component explorer
43+
`npm run storybook`
44+
45+
Build storybook component explorer as standalone app (outputs to "storybook-static" dir)
46+
`npm run build:storybook`
47+
4248
## Configurations
4349
* [TypeScript Config](./tsconfig.json)
4450
* [Webpack Config](./webpack.common.js)
@@ -83,3 +89,14 @@ body {
8389
* To keep our code formatting in check, we use [prettier](https://github.com/prettier/prettier)
8490
* To keep our code logic and test coverage in check, we use [jest](https://github.com/facebook/jest)
8591
* To ensure code styles remain consistent, we use [eslint](https://eslint.org/)
92+
* To provide a place to showcase custom components, we integrate with [storybook](https://storybook.js.org/)
93+
94+
## Multi environment configuration
95+
This project uses [dotenv-webpack](https://www.npmjs.com/package/dotenv-webpack) for exposing environment variables to your code. Either export them at the system level like `export MY_ENV_VAR=http://dev.myendpoint.com && npm run start:dev` or simply drop a `.env` file in the root that contains your key-value pairs like below:
96+
97+
```sh
98+
ENV_1=http://1.myendpoint.com
99+
ENV_2=http://2.myendpoint.com
100+
```
101+
102+
With that in place, you can use the values in your code like `console.log(process.env.ENV_1);`

0 commit comments

Comments
 (0)