Skip to content

Commit 511078f

Browse files
authored
fix(cli): fix default NODE_ENV of command (#2724)
chore: fix default NODE_ENV of command
1 parent d28a9d0 commit 511078f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/rspack-cli/src/rspack-cli.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,20 @@ export class RspackCLI {
2929
}
3030
async createCompiler(
3131
options: RspackCLIOptions,
32-
rspackEnv: Command,
32+
rspackCommand: Command,
3333
callback?: (e: Error, res?: Stats | MultiStats) => void
3434
): Promise<Compiler | MultiCompiler> {
3535
process.env.RSPACK_CONFIG_VALIDATE = "loose";
3636
let nodeEnv = process?.env?.NODE_ENV;
37+
let rspackCommandDefaultEnv =
38+
rspackCommand === "build" ? "production" : "development";
3739
if (typeof options.nodeEnv === "string") {
3840
process.env.NODE_ENV = nodeEnv || options.nodeEnv;
3941
} else {
40-
process.env.NODE_ENV = nodeEnv || rspackEnv;
42+
process.env.NODE_ENV = nodeEnv || rspackCommandDefaultEnv;
4143
}
4244
let config = await this.loadConfig(options);
43-
config = await this.buildConfig(config, options, rspackEnv);
45+
config = await this.buildConfig(config, options, rspackCommand);
4446

4547
const isWatch = Array.isArray(config)
4648
? (config as MultiRspackOptions).some(i => i.watch)

0 commit comments

Comments
 (0)