Skip to content

Conversation

@pete-the-pete
Copy link

@pete-the-pete pete-the-pete commented Jan 10, 2026

Summary

Addresses #90, specifically this comment requesting support for loading .env files from nested directories in monorepo setups.

Changes

This PR adds comprehensive monorepo support to intelligently locate and load .env files in multi-package workspaces.

Core Functionality:

  • Smart .env File Discovery: Implements findNearestEnvFile() that walks up the directory tree from the active file to locate the nearest .env file, respecting workspace boundaries
  • Priority System: Establishes a priority order for .env files (.env.local > .env > others), allowing package-specific overrides while falling back to shared root configuration
  • Caching Layer: Adds memoization for discovered .env files to improve performance

Configuration:

  • Adds new setting dotenv.enableMonorepoSupport (enabled by default)
  • When enabled, uses the active file's directory as the starting point for .env discovery
  • When disabled, falls back to original behavior of using workspace root

File Watching:

  • Implements file system watcher for .env* files to detect changes
  • Automatically clears the memoization cache when files change

🤖 Generated with Claude Code

Search for .env files starting from the active file's directory and
walking up the tree. Supports priority ordering (.env.local before .env)
and caches results for performance. File watcher invalidates cache when
.env files change.

New setting: dotenv.enableMonorepoSupport (default: true)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant