Skip to content

Commit 9e85d1d

Browse files
authored
examples/vite.config.ts: check for required environment variables (#4578)
## Motivation Make it harder to accidentally deploy the demo apps without setting their required environment variables. ## Proposal Add a Vite plugin that checks the requisite variables are set (though not sensible) at build time. ## Test Plan Tested manually. ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent 966b655 commit 9e85d1d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

examples/vite.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
import { defineConfig } from 'vite';
22
import path from 'path';
33

4+
const checkEnvironment = envs => {
5+
const missing = envs.filter(env => !(env in process.env));
6+
if (missing.length > 0)
7+
throw new Error(`required environment variables missing: ${missing.toString()}`);
8+
9+
return {
10+
name: 'checkEnvironment',
11+
};
12+
}
13+
414
// https://vitejs.dev/config/
515
export default defineConfig({
616
base: '',
717
envPrefix: 'LINERA_',
18+
plugins: [
19+
checkEnvironment([
20+
'LINERA_FAUCET_URL',
21+
'LINERA_APPLICATION_ID',
22+
]),
23+
],
824
server: {
925
headers: {
1026
'Cross-Origin-Embedder-Policy': 'require-corp',

0 commit comments

Comments
 (0)