Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): support buildTarget that excludes project name #20508

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions e2e/web/src/file-server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ describe('file-server', () => {
setMaxWorkers(join('apps', appName, 'project.json'));
updateJson(join('apps', appName, 'project.json'), (config) => {
config.targets['serve'].executor = '@nx/web:file-server';
// Check that buildTarget can exclude project name (e.g. build vs proj:build).
config.targets['serve'].options.buildTarget = 'build';
return config;
});

Expand Down
14 changes: 11 additions & 3 deletions packages/web/src/executors/file-server/file-server.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,16 @@ function getHttpServerArgs(options: Schema) {
return args;
}

function getBuildTargetCommand(options: Schema) {
const cmd = ['nx', 'run', options.buildTarget];
function getBuildTargetCommand(options: Schema, context: ExecutorContext) {
const target = parseTargetString(options.buildTarget, context);
const cmd = ['nx', 'run'];

if (target.configuration) {
cmd.push(`${target.project}:${target.target}:${target.configuration}`);
} else {
cmd.push(`${target.project}:${target.target}`);
}

if (options.parallel) {
cmd.push(`--parallel`);
}
Expand Down Expand Up @@ -131,7 +139,7 @@ export default async function* fileServerExecutor(
if (!running) {
running = true;
try {
const args = getBuildTargetCommand(options);
const args = getBuildTargetCommand(options, context);
execFileSync(pmCmd, args, {
stdio: [0, 1, 2],
});
Expand Down