-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
40 lines (34 loc) · 1.08 KB
/
vite.config.ts
File metadata and controls
40 lines (34 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
function envValidationPlugin(env: Record<string, string>) {
return {
name: "vite-plugin-env-validation", // name of the plugin
config() {
const requiredEnvVars = ["VITE_SUPABASE_URL", "VITE_SUPABASE_ANON_KEY"]; // list of required env variables
const missingEnvVars = requiredEnvVars.filter((envVar) => !env[envVar]);
if (missingEnvVars.length > 0) {
// Display error message with emojis
throw new Error(
`❌ Missing required environment variables: ${missingEnvVars.join(
", "
)} 😞`
);
}
// Success message with emoji
console.log("✅ All required environment variables are set. 🎉");
},
};
}
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
return {
plugins: [vue(), envValidationPlugin(env)],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
};
});