Skip to content

Commit

Permalink
fix: env vars optional
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Dec 1, 2023
1 parent ea0c7bd commit b17507f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions build/esbuild-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ const entries = [
];

export const esBuildContext: esbuild.BuildOptions = {
define: {
"process.env.GITHUB_TOKEN": JSON.stringify(process.env.GITHUB_TOKEN),
"process.env.SUPABASE_URL": JSON.stringify(process.env.SUPABASE_URL),
"process.env.SUPABASE_KEY": JSON.stringify(process.env.SUPABASE_KEY),
},
define: createEnvDefines(["GITHUB_TOKEN", "SUPABASE_URL", "SUPABASE_KEY"]),

sourcemap: true,
entryPoints: entries,
bundle: true,
Expand All @@ -42,3 +39,14 @@ esbuild
console.error(err);
process.exit(1);
});

function createEnvDefines(variableNames: string[]): Record<string, string> {
const defines: Record<string, string> = {};
for (const name of variableNames) {
const envVar = process.env[name];
if (envVar !== undefined) {
defines[`process.env.${name}`] = JSON.stringify(envVar);
}
}
return defines;
}
2 changes: 1 addition & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GitHub Issues Viewer</title>
<title>DevPool Directory | Ubiquity DAO</title>
<link rel="stylesheet" href="style/style.css" />
</head>
<body>
Expand Down

0 comments on commit b17507f

Please sign in to comment.