From f5b92af4f9dea4fe17a38251631c9536160bdb36 Mon Sep 17 00:00:00 2001 From: shreerang Date: Wed, 4 Jun 2025 12:31:44 +0000 Subject: [PATCH] Setup `import-meta-env` to configure env at runtime (#32) Part of https://www.notion.so/Stage0-onboarding-flow-1e4a6b22d47280aba3b5da3ed1154ff5 Co-authored-by: Shreerang Kale Co-authored-by: Nabarun Reviewed-on: https://git.vdb.to/LaconicNetwork/laconic-wallet-web/pulls/32 Co-authored-by: shreerang Co-committed-by: shreerang --- config-overrides.js | 6 +- package.json | 10 +- public/index.html | 3 + src/hooks/useAddAccountEmbed.ts | 2 +- src/hooks/useGetOrCreateAccounts.ts | 2 +- src/import-meta-env.d.ts | 14 ++ src/screens/AddNetwork.tsx | 2 +- src/screens/ApproveTransaction.tsx | 2 +- src/screens/ApproveTransfer.tsx | 2 +- src/screens/AutoSignIn.tsx | 2 +- src/screens/SignRequestEmbed.tsx | 2 +- src/screens/SignTxEmbed.tsx | 2 +- src/screens/WalletEmbed.tsx | 2 +- src/utils/constants.ts | 6 +- .../wallet-connect/WalletConnectUtils.tsx | 2 +- stack/stack-orchestrator/config/app/run.sh | 16 +- .../cerc-laconic-wallet-web/Dockerfile | 4 +- yarn.lock | 168 ++++++++++++++++-- 18 files changed, 211 insertions(+), 36 deletions(-) create mode 100644 src/import-meta-env.d.ts diff --git a/config-overrides.js b/config-overrides.js index af26d75..4b7adbe 100644 --- a/config-overrides.js +++ b/config-overrides.js @@ -31,7 +31,11 @@ module.exports = function override(config, env) { config.plugins.push( new webpack.ProvidePlugin({ Buffer: ["buffer", "Buffer"], - }) + }), + require("@import-meta-env/unplugin").webpack({ + example: ".env.example", + env: ".env", + }), ) config.module.rules.push({ diff --git a/package.json b/package.json index 8d8b52d..862ee0a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "web-wallet", - "version": "0.1.5", + "version": "0.1.6", "private": true, "dependencies": { "@cerc-io/registry-sdk": "^0.2.5", @@ -52,6 +52,7 @@ "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", + "set-env": "import-meta-env -x .env.example -p build/index.html", "test": "react-app-rewired test", "lint": "eslint .", "prepare": "husky", @@ -77,6 +78,9 @@ }, "devDependencies": { "@babel/plugin-transform-modules-commonjs": "^7.24.8", + "@import-meta-env/cli": "^0.7.3", + "@import-meta-env/typescript": "^0.4.0", + "@import-meta-env/unplugin": "^0.6.2", "@types/json-bigint": "^1.0.4", "@types/lodash": "^4.17.7", "@types/node": "^16.7.13", @@ -85,6 +89,7 @@ "@typescript-eslint/eslint-plugin": "^6.13.2", "@typescript-eslint/parser": "^6.13.2", "crypto-browserify": "^3.12.0", + "dotenv": "^16.5.0", "eslint": "^8.3.0", "eslint-config-react-app": "^7.0.1", "eslint-plugin-react": "^7.33.2", @@ -92,5 +97,6 @@ "husky": "^9.0.11", "react-app-rewired": "^2.2.1", "stream-browserify": "^3.0.0" - } + }, + "packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447" } diff --git a/public/index.html b/public/index.html index f863862..25b8db1 100644 --- a/public/index.html +++ b/public/index.html @@ -28,6 +28,9 @@ Learn how to configure a non-root public URL by running `npm run build`. --> Laconic Wallet +