Skip to content

Commit 4ff66c1

Browse files
authored
Merge pull request #30 from Libertai/aliel/fix-env-export
fix env: export env in browser context
2 parents 919659d + 5904c83 commit 4ff66c1

File tree

6 files changed

+31
-14
lines changed

6 files changed

+31
-14
lines changed

.env.example

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Use the testnet in development
2-
# ALEPH_API_URL=https://api.twentysix.testnet.network
2+
# APP.ALEPH_API_URL=https://api.twentysix.testnet.network
33

44
# WalletConnect
5-
WALLET_CONNECT_PROJECT_ID=
5+
APP.WALLET_CONNECT_PROJECT_ID=
66

77
# APIs
8-
LTAI_SUBSCRIPTIONS_API_URL=http://localhost:8000
9-
LTAI_AGENTS_API_URL=http://localhost:8001
8+
APP.LTAI_SUBSCRIPTIONS_API_URL=http://localhost:8000
9+
APP.LTAI_AGENTS_API_URL=http://localhost:8001
1010

1111
# RPCs
12-
SOLANA_RPC=
12+
APP.SOLANA_RPC=
1313

1414
# Blockchain addresses (change in development)
15-
# LTAI_BASE_ADDRESS=0x92e1d72210429Ce7eE8a0d64D526D4b9752801FF
16-
# LTAI_SOLANA_ADDRESS=5ooRTqmvm95bHwp4HMo3iszCwsEseY5hksfSa9EDVpBY
17-
# LTAI_PUBLISHER_ADDRESS=0xae92Dc50115dbBb1CF0BA848e83842daf00CE129
18-
# WAGMI_BASE_ID=84532
15+
# APP.LTAI_BASE_ADDRESS=0x92e1d72210429Ce7eE8a0d64D526D4b9752801FF
16+
# APP.LTAI_SOLANA_ADDRESS=5ooRTqmvm95bHwp4HMo3iszCwsEseY5hksfSa9EDVpBY
17+
# APP.LTAI_PUBLISHER_ADDRESS=0xae92Dc50115dbBb1CF0BA848e83842daf00CE129
18+
# APP.WAGMI_BASE_ID=84532

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"tailwindcss": "^3.4.14",
8282
"typescript": "^5.6.3",
8383
"vite-plugin-checker": "^0.7.2",
84+
"vite-plugin-environment": "^1.1.3",
8485
"vite-plugin-node-polyfills": "^0.22.0",
8586
"vue-eslint-parser": "^9.4.3",
8687
"vue-tsc": "^2.0.29"

quasar.config.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
const { configure } = require('quasar/wrappers');
1212
const { nodePolyfills } = require('vite-plugin-node-polyfills');
13+
const EnvironmentPlugin = require('vite-plugin-environment').default;
1314

1415
module.exports = configure(function (ctx) {
1516
return {
@@ -70,7 +71,14 @@ module.exports = configure(function (ctx) {
7071
if (viteConf.plugins === undefined) {
7172
viteConf.plugins = [];
7273
}
73-
viteConf.plugins = [...viteConf.plugins, nodePolyfills()];
74+
viteConf.plugins = [
75+
...viteConf.plugins,
76+
nodePolyfills(),
77+
EnvironmentPlugin('all', {
78+
prefix: 'APP.',
79+
defineOn: 'import.meta.env',
80+
}),
81+
];
7482
if (ctx.dev) {
7583
viteConf.define['process.browser'] = true;
7684
}

src/boot/utils.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import dayjs from 'dayjs';
22
import localizedFormat from 'dayjs/plugin/localizedFormat';
33
import relativeTime from 'dayjs/plugin/relativeTime';
44
import * as pdfjs from 'pdfjs-dist';
5-
import { boot } from 'quasar/wrappers';
6-
// @ts-expect-error
75
import workerSrc from 'pdfjs-dist/build/pdf.worker?worker&url';
6+
import { boot } from 'quasar/wrappers';
87

98
export default boot(() => {
109
dayjs.extend(localizedFormat);

src/config/env.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ const envSchema = z.object({
1313
WAGMI_BASE_ID: z.union([z.literal(base.id), z.literal(baseSepolia.id)]).default(base.id),
1414
});
1515

16-
const env = envSchema.parse(process.env);
16+
const env = envSchema.parse(
17+
Object.keys(import.meta.env).reduce(
18+
(acc, key) => ({
19+
...acc,
20+
...{ [key.replace('APP.', '')]: import.meta.env[key] },
21+
}),
22+
{},
23+
),
24+
);
1725

1826
export default env;

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"allowJs": false,
55
"baseUrl": ".",
66
"target": "ESNext",
7-
"skipLibCheck": true
7+
"skipLibCheck": true,
8+
"types": ["node", "vite/client"]
89
},
910
"exclude": [
1011
"./dist",

0 commit comments

Comments
 (0)