forked from huhusmang/Subscription-Management
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.env.js
More file actions
29 lines (24 loc) · 853 Bytes
/
Copy pathvite.env.js
File metadata and controls
29 lines (24 loc) · 853 Bytes
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
// This file helps with environment variables in Vite
// It's loaded by vite.config.ts
const loadEnv = () => {
const env = {};
// Try to load from .env.local (highest priority)
try {
const fs = require('fs');
const path = require('path');
const dotenv = require('dotenv');
// Load environment variables from .env files
['', '.local', '.development', '.production'].forEach(suffix => {
const envPath = path.resolve(process.cwd(), `.env${suffix}`);
if (fs.existsSync(envPath)) {
const envConfig = dotenv.parse(fs.readFileSync(envPath));
Object.assign(env, envConfig);
console.log(`Loaded environment variables from .env${suffix}`);
}
});
} catch (err) {
console.error('Error loading environment variables:', err);
}
return env;
};
module.exports = { loadEnv };