Monorepo Support

In monorepos with multiple applications and shared packages, environment variables are often used across folder boundaries. dotenv-diff supports this by allowing you to extend the scan scope to include shared folders while still running from a single app.

Scanning Shared Packages

By default, dotenv-diff scans the current working directory. In a monorepo, you can include shared packages or libraries using the --include-files flag.

package.json
{
  "scripts": {
    "dotenv-diff": "dotenv-diff --example .env.example --include-files '../../packages/**/*' --ignore VITE_MODE"
  }
}

What This Does

  • Scans the current application.
  • Includes shared packages from the monorepo.
  • Detects environment variable usage across app and shared code.
  • Ignores variables used only in specific runtime environments.

Using a Configuration File

For larger monorepos, it is often cleaner to move shared configuration into a dotenv-diff.config.json file.

dotenv-diff.config.json
{
  "example": ".env.example",
  "includeFiles": ["../../packages/**/*"],
  "ignore": ["VITE_MODE"]
}

Why This Matters in Monorepos

  • Unused or undocumented variables are harder to detect across apps.
  • Keeping .env.example accurate becomes more complex at scale.