Skip to content

Commit 709067e

Browse files
committed
fix: devtool cmd line not work and default value
1 parent 537e8c5 commit 709067e

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

packages/rspack-cli/src/cli.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ export class RspackCLI {
172172
if (typeof item.devtool === "undefined") {
173173
item.devtool = isBuild ? "source-map" : "cheap-module-source-map";
174174
}
175+
// user parameters always has highest priority than default devtool and config devtool
176+
if (typeof options.devtool !== "undefined") {
177+
item.devtool = options.devtool as RspackOptions["devtool"];
178+
}
179+
175180
if (isServe) {
176181
const installed = (item.plugins ||= []).find(
177182
item => item instanceof rspackCore.ProgressPlugin

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,15 @@ export const commonOptionsForBuildAndServe = (yargs: yargs.Argv) => {
5858
describe: "env passed to config function"
5959
},
6060
devtool: {
61-
type: "boolean",
62-
default: false,
61+
type: "string",
62+
default: "eval",
6363
describe: "devtool",
64-
alias: "d"
64+
alias: "d",
65+
coerce: arg => {
66+
if (arg === "true") return "eval"; // --devtool true 等价于 "eval"
67+
if (arg === "false") return false; // --devtool false 表示禁用
68+
return arg;
69+
}
6570
}
6671
})
6772
.alias({ v: "version", h: "help" });

0 commit comments

Comments
 (0)