File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { join } from 'node:path';
44// Simple .env loader without external dependencies
55function loadEnvFile ( filePath : string ) {
66 if ( ! existsSync ( filePath ) ) {
7+ console . warn ( `Warning: File ${ filePath } not found` ) ;
78 return ;
89 }
910
@@ -24,12 +25,22 @@ function loadEnvFile(filePath: string) {
2425 }
2526 }
2627 }
28+ console . log ( `✅ Loaded: ${ filePath } ` ) ;
2729 } catch ( error ) {
2830 console . warn ( `Warning: Could not load ${ filePath } ` ) ;
29- console . warn ( 'Make sure a valid .env.local file exists.' ) ;
3031 console . warn ( error ) ;
3132 }
3233}
3334
34- // Load local environment file if it exists
35- loadEnvFile ( join ( process . cwd ( ) , '.env.local' ) ) ;
35+ // Determine environment (defaults to development)
36+ const nodeEnv = process . env . NODE_ENV || 'development' ;
37+ console . log ( `🌍 Environment: ${ nodeEnv } ` ) ;
38+
39+ // Load environment-specific config first (public values)
40+ const envFile = join ( process . cwd ( ) , `.env.${ nodeEnv } ` ) ;
41+ loadEnvFile ( envFile ) ;
42+
43+ // Load local overrides and secrets second (overrides public config)
44+ // Required in both dev and prod for DISCORD_TOKEN
45+ const localEnvFile = join ( process . cwd ( ) , '.env.local' ) ;
46+ loadEnvFile ( localEnvFile ) ;
You can’t perform that action at this time.
0 commit comments