Fix env.ts path resolution for both dev (src/) and prod (dist/src/)
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
import { config } from 'dotenv';
|
||||
import { resolve } from 'path';
|
||||
import { existsSync } from 'fs';
|
||||
|
||||
config({ path: resolve(import.meta.dirname, '../../../.env') });
|
||||
// Works from both src/ (dev) and dist/src/ (prod)
|
||||
const envPath = [
|
||||
resolve(import.meta.dirname, '../../../.env'),
|
||||
resolve(import.meta.dirname, '../../../../.env'),
|
||||
].find(p => existsSync(p));
|
||||
|
||||
if (envPath) config({ path: envPath });
|
||||
|
||||
Reference in New Issue
Block a user