Skip to content

Commit b0ae68c

Browse files
Merge pull request #3283 from nestjs/copilot/sub-pr-3280-again
fix: support CLI rspackPath override in getRspackConfigPath
2 parents 49b63e2 + 671d402 commit b0ae68c

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

lib/compiler/helpers/get-rspack-config-path.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { getValueOrDefault } from './get-value-or-default.js';
33

44
/**
55
* Returns the path to the rspack configuration file to use for the given application.
6+
* CLI option `rspackPath` takes precedence over the configuration file.
67
* @param configuration Configuration object.
78
* @param cmdOptions Command line options.
89
* @param appName Application name.
@@ -13,6 +14,10 @@ export function getRspackConfigPath(
1314
cmdOptions: Record<string, any>,
1415
appName: string | undefined,
1516
) {
17+
if (cmdOptions?.rspackPath) {
18+
return cmdOptions.rspackPath as string;
19+
}
20+
1621
const builder = getValueOrDefault<Builder>(
1722
configuration,
1823
'compilerOptions.builder',

test/lib/compiler/helpers/get-rspack-config-path.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,21 @@ describe('getRspackConfigPath', () => {
9999
const result = getRspackConfigPath(config, {}, 'my-app');
100100
expect(result).toBe('apps/my-app/rspack.config.js');
101101
});
102+
103+
it('should return the CLI rspackPath option when provided', () => {
104+
const config = makeConfiguration({
105+
compilerOptions: {
106+
builder: {
107+
type: 'rspack',
108+
options: { configPath: 'rspack.config.js' },
109+
},
110+
},
111+
});
112+
const result = getRspackConfigPath(
113+
config,
114+
{ rspackPath: 'custom-cli-rspack.config.ts' },
115+
undefined,
116+
);
117+
expect(result).toBe('custom-cli-rspack.config.ts');
118+
});
102119
});

0 commit comments

Comments
 (0)