vasuzex 2.1.25 → 2.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,16 +15,19 @@ const require = createRequire(import.meta.url);
|
|
|
15
15
|
// Load environment variables based on NODE_ENV
|
|
16
16
|
const loadEnvFiles = () => {
|
|
17
17
|
const cwd = process.cwd();
|
|
18
|
-
const nodeEnv = process.env.NODE_ENV || 'development';
|
|
19
18
|
|
|
20
|
-
// Load base .env first
|
|
19
|
+
// Step 1: Load base .env first (to get NODE_ENV)
|
|
21
20
|
dotenv.config({ path: resolve(cwd, '.env') });
|
|
22
21
|
|
|
23
|
-
//
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
// Step 2: Now check NODE_ENV and load environment-specific file
|
|
23
|
+
const nodeEnv = process.env.NODE_ENV;
|
|
24
|
+
if (nodeEnv && nodeEnv !== 'development') {
|
|
25
|
+
const envFile = `.env.${nodeEnv}`;
|
|
26
|
+
const envPath = resolve(cwd, envFile);
|
|
27
|
+
if (existsSync(envPath)) {
|
|
28
|
+
// Override base .env with environment-specific values
|
|
29
|
+
dotenv.config({ path: envPath, override: true });
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
32
|
};
|
|
30
33
|
|