-
-
Notifications
You must be signed in to change notification settings - Fork 201
Open
Description
Summary
Moon currently supports a single static envFile per task. Nx provides built-in dotenv resolution that automatically loads env files based on target and configuration with an ordered precedence (target+config, config-only, target-only, general, plus .local variants, skipping .local in CI). See Nx docs: https://nx.dev/docs/guides/tips-n-tricks/define-environment-variables.
Problem
- Migrating from Nx requires recreating Nx's env loading semantics manually. There is no built-in way to stack multiple env files (base, base.local, target, target.local, target+config, etc.) and to honor CI skipping of .local.
envFileis single-file and static; no target/config-aware resolution.
Desired behavior / parity with Nx
- Built-in dotenv resolution that mirrors Nx's precedence for target/config: load env files for target+config (and .local), then config-only (and .local), then target-only (and .local), then general (.env/.env.local), ignoring missing files and skipping .local in CI by default.
- Support both project-root and workspace-root env files (as Nx does) with the same precedence rules.
- Allow optional runtime override for target/config (env vars or CLI) without duplicating tasks.
Possible implementation avenues
- Extend task options to support multiple env files via tokens (e.g., @target, @config) and a
loadLocaltoggle (default skip in CI). - Or a workspace-level dotenv resolution setting applied automatically to all tasks with opt-out.
- Alternatively, extend plugin/task lifecycle hooks so a WASM plugin can intercept task execution to apply Nx-like dotenv resolution.
Motivation
- Feature parity with Nx for dotenv handling removes migration friction, reduces boilerplate, and clarifies env loading semantics for Moon users coming from Nx.
Metadata
Metadata
Assignees
Labels
No labels