Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/rspack-cli/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface RspackCLIOptions {
config?: string;
argv?: Record<string, any>;
configName?: string[];
"config-loader"?: string;
}

export interface RspackBuildCLIOptions extends RspackCLIOptions {
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-cli/src/utils/loadConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ export async function loadRspackConfig(
if (!fs.existsSync(configPath)) {
throw new Error(`config file "${configPath}" not found.`);
}
if (isTsFile(configPath)) {
if (isTsFile(configPath) && options['config-loader'] === 'register') {
await registerLoader(configPath);
}
return crossImport(configPath, cwd);
}

const defaultConfig = findConfig(path.resolve(cwd, DEFAULT_CONFIG_NAME));
if (defaultConfig) {
if (isTsFile(defaultConfig)) {
if (isTsFile(defaultConfig) && options['config-loader'] === 'register') {
await registerLoader(defaultConfig);
}
return crossImport(defaultConfig, cwd);
Expand Down
7 changes: 6 additions & 1 deletion packages/rspack-cli/src/utils/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ export const commonOptions = (yargs: yargs.Argv) => {
type: "array",
string: true,
describe: "Name of the configuration to use."
}
},
'config-loader': {
type: "string",
default: "register",
describe: "Specify the loader to load the config file, can be `native` or `register`.",
},
})
.alias({ v: "version", h: "help" });
};
Expand Down
Loading