Skip to content

Commit

Permalink
Merge pull request #30 from Libertai/aliel/fix-env-export
Browse files Browse the repository at this point in the history
fix env: export env in browser context
  • Loading branch information
aliel authored Nov 24, 2024
2 parents 919659d + 5904c83 commit 4ff66c1
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 14 deletions.
18 changes: 9 additions & 9 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Use the testnet in development
# ALEPH_API_URL=https://api.twentysix.testnet.network
# APP.ALEPH_API_URL=https://api.twentysix.testnet.network

# WalletConnect
WALLET_CONNECT_PROJECT_ID=
APP.WALLET_CONNECT_PROJECT_ID=

# APIs
LTAI_SUBSCRIPTIONS_API_URL=http://localhost:8000
LTAI_AGENTS_API_URL=http://localhost:8001
APP.LTAI_SUBSCRIPTIONS_API_URL=http://localhost:8000
APP.LTAI_AGENTS_API_URL=http://localhost:8001

# RPCs
SOLANA_RPC=
APP.SOLANA_RPC=

# Blockchain addresses (change in development)
# LTAI_BASE_ADDRESS=0x92e1d72210429Ce7eE8a0d64D526D4b9752801FF
# LTAI_SOLANA_ADDRESS=5ooRTqmvm95bHwp4HMo3iszCwsEseY5hksfSa9EDVpBY
# LTAI_PUBLISHER_ADDRESS=0xae92Dc50115dbBb1CF0BA848e83842daf00CE129
# WAGMI_BASE_ID=84532
# APP.LTAI_BASE_ADDRESS=0x92e1d72210429Ce7eE8a0d64D526D4b9752801FF
# APP.LTAI_SOLANA_ADDRESS=5ooRTqmvm95bHwp4HMo3iszCwsEseY5hksfSa9EDVpBY
# APP.LTAI_PUBLISHER_ADDRESS=0xae92Dc50115dbBb1CF0BA848e83842daf00CE129
# APP.WAGMI_BASE_ID=84532
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"tailwindcss": "^3.4.14",
"typescript": "^5.6.3",
"vite-plugin-checker": "^0.7.2",
"vite-plugin-environment": "^1.1.3",
"vite-plugin-node-polyfills": "^0.22.0",
"vue-eslint-parser": "^9.4.3",
"vue-tsc": "^2.0.29"
Expand Down
10 changes: 9 additions & 1 deletion quasar.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

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

module.exports = configure(function (ctx) {
return {
Expand Down Expand Up @@ -70,7 +71,14 @@ module.exports = configure(function (ctx) {
if (viteConf.plugins === undefined) {
viteConf.plugins = [];
}
viteConf.plugins = [...viteConf.plugins, nodePolyfills()];
viteConf.plugins = [
...viteConf.plugins,
nodePolyfills(),
EnvironmentPlugin('all', {
prefix: 'APP.',
defineOn: 'import.meta.env',
}),
];
if (ctx.dev) {
viteConf.define['process.browser'] = true;
}
Expand Down
3 changes: 1 addition & 2 deletions src/boot/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import dayjs from 'dayjs';
import localizedFormat from 'dayjs/plugin/localizedFormat';
import relativeTime from 'dayjs/plugin/relativeTime';
import * as pdfjs from 'pdfjs-dist';
import { boot } from 'quasar/wrappers';
// @ts-expect-error
import workerSrc from 'pdfjs-dist/build/pdf.worker?worker&url';
import { boot } from 'quasar/wrappers';

export default boot(() => {
dayjs.extend(localizedFormat);
Expand Down
10 changes: 9 additions & 1 deletion src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ const envSchema = z.object({
WAGMI_BASE_ID: z.union([z.literal(base.id), z.literal(baseSepolia.id)]).default(base.id),
});

const env = envSchema.parse(process.env);
const env = envSchema.parse(
Object.keys(import.meta.env).reduce(
(acc, key) => ({
...acc,
...{ [key.replace('APP.', '')]: import.meta.env[key] },
}),
{},
),
);

export default env;
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"allowJs": false,
"baseUrl": ".",
"target": "ESNext",
"skipLibCheck": true
"skipLibCheck": true,
"types": ["node", "vite/client"]
},
"exclude": [
"./dist",
Expand Down

0 comments on commit 4ff66c1

Please sign in to comment.