Skip to content

Commit

Permalink
wallet-ext: dotenv
Browse files Browse the repository at this point in the history
* uses `.env` file in `configs/environment/` to specify variables for the current envionment, if needed, and `.env.defaults` for default values
  • Loading branch information
pchrysochoidis committed May 31, 2022
1 parent 8f7e011 commit 3642552
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 0 deletions.
1 change: 1 addition & 0 deletions wallet/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.DS_Store
node_modules
dist
configs/environment/.env
8 changes: 8 additions & 0 deletions wallet/configs/environment/.env.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Default values for some env variables. Use .env to add/change variables for the
# current environment.

API_ENV=devNet
API_ENDPOINT_LOCAL=http://127.0.0.1:5001
API_ENDPOINT_DEV_NET=https://gateway.devnet.sui.io
EXPLORER_URL_LOCAL=http://localhost:8080/
EXPLORER_URL_DEV_NET=https://explorer.devnet.sui.io/
6 changes: 6 additions & 0 deletions wallet/configs/webpack/webpack.config.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { exec } from 'child_process';
import CopyPlugin from 'copy-webpack-plugin';
import DotEnv from 'dotenv-webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import { resolve } from 'path';
Expand Down Expand Up @@ -150,6 +151,11 @@ const commonConfig: () => Promise<Configuration> = async () => {
},
],
}),
new DotEnv({
path: resolve(CONFIGS_ROOT, 'environment', '.env'),
defaults: resolve(CONFIGS_ROOT, 'environment', '.env.defaults'),
expand: true,
}),
new DefinePlugin({
'typeof window': JSON.stringify(typeof {}),
'process.env.NODE_DEBUG': false,
Expand Down
81 changes: 81 additions & 0 deletions wallet/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"author": "Mysten Labs <[email protected]>",
"license": "Apache-2.0",
"devDependencies": {
"@types/dotenv-webpack": "^7.0.3",
"@types/jest": "^27.5.0",
"@types/node": "^17.0.31",
"@types/react": "^18.0.8",
Expand All @@ -42,6 +43,7 @@
"copy-webpack-plugin": "^10.2.4",
"cross-env": "^7.0.3",
"css-loader": "^6.7.1",
"dotenv-webpack": "^7.1.0",
"eslint": "^8.14.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-react-app": "^7.0.1",
Expand Down

0 comments on commit 3642552

Please sign in to comment.