diff --git a/src/cli.zig b/src/cli.zig index 078db88bc4..a156089f4d 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -414,7 +414,7 @@ pub const Command = struct { production: bool = false, - env_behavior: api.DotEnvBehavior = .load_all_without_inlining, + env_behavior: api.DotEnvBehavior = .disable, env_prefix: []const u8 = "", elide_lines: ?usize = null, // Compile options @@ -433,6 +433,13 @@ pub const Command = struct { .allocator = allocator, }; global_cli_ctx = &context_data; + + // Set appropriate default env_behavior based on command + // Build command uses .disable as default (env vars handled via define mechanism) + // Run/Test/other commands use .load_all_without_inlining as default + if (comptime command != .BuildCommand) { + global_cli_ctx.bundler_options.env_behavior = .load_all_without_inlining; + } if (comptime Command.Tag.uses_global_options.get(command)) { global_cli_ctx.args = try Arguments.parse(allocator, global_cli_ctx, command);