(projectDir: string)
| 15 | * @returns Object containing environment variables |
| 16 | */ |
| 17 | export function loadEnvConfig(projectDir: string): EnvConfig { |
| 18 | const envPath = path.join(projectDir, '.env'); |
| 19 | |
| 20 | if (!existsSync(envPath)) { |
| 21 | return {}; |
| 22 | } |
| 23 | |
| 24 | try { |
| 25 | const envConfig = dotenvConfig({path: envPath}); |
| 26 | return envConfig.parsed || {}; |
| 27 | } catch (error) { |
| 28 | console.warn(`Warning: Failed to load .env file at ${envPath}:`, error); |
| 29 | return {}; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Get webpack DefinePlugin definitions for environment variables |
no test coverage detected