<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #25284
45 lines
941 B
TypeScript
45 lines
941 B
TypeScript
import type { Tree } from '@nx/devkit';
|
|
import {
|
|
generateFiles,
|
|
joinPathFragments,
|
|
readProjectConfiguration,
|
|
} from '@nx/devkit';
|
|
import type { Schema } from '../schema';
|
|
|
|
export function generateSSRFiles(
|
|
tree: Tree,
|
|
schema: Schema,
|
|
isUsingApplicationBuilder: boolean
|
|
) {
|
|
const { root: projectRoot, targets } = readProjectConfiguration(
|
|
tree,
|
|
schema.project
|
|
);
|
|
|
|
if (
|
|
targets.server ||
|
|
(isUsingApplicationBuilder && targets.build.options?.server !== undefined)
|
|
) {
|
|
// server has already been added
|
|
return;
|
|
}
|
|
|
|
const pathToFiles = joinPathFragments(__dirname, '..', 'files');
|
|
|
|
if (schema.standalone) {
|
|
generateFiles(
|
|
tree,
|
|
joinPathFragments(pathToFiles, 'standalone'),
|
|
projectRoot,
|
|
{ ...schema, tpl: '' }
|
|
);
|
|
} else {
|
|
generateFiles(
|
|
tree,
|
|
joinPathFragments(pathToFiles, 'ngmodule'),
|
|
projectRoot,
|
|
{ ...schema, tpl: '' }
|
|
);
|
|
}
|
|
}
|