fix(nextjs): Ensure build-custom-server is only added once to nx.json (#18972)

This commit is contained in:
Nicholas Cunningham 2023-09-01 13:41:47 -06:00 committed by GitHub
parent f3f12d4201
commit b42be17e52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,6 @@ import {
updateJson,
convertNxGenerator,
generateFiles,
joinPathFragments,
logger,
offsetFromRoot,
readProjectConfiguration,
@ -100,12 +99,18 @@ export async function customServerGenerator(
updateProjectConfiguration(host, options.project, project);
updateJson(host, 'nx.json', (json) => {
if (
!json.tasksRunnerOptions?.default?.options?.cacheableOperations?.includes(
'build-custom-server'
)
) {
json.tasksRunnerOptions ??= {};
json.tasksRunnerOptions.default ??= { options: {} };
json.tasksRunnerOptions.default.options.cacheableOperations = [
...json.tasksRunnerOptions.default.options.cacheableOperations,
'build-custom-server',
];
}
return json;
});
}