Skip to content

Commit

Permalink
fix(angular): cache server build
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Dec 20, 2022
1 parent e53303b commit 61dd390
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Expand Up @@ -2,7 +2,9 @@ import type { Tree } from '@nrwl/devkit';
import {
joinPathFragments,
readProjectConfiguration,
readWorkspaceConfiguration,
updateProjectConfiguration,
updateWorkspaceConfiguration,
} from '@nrwl/devkit';
import type { Schema } from '../schema';

Expand Down Expand Up @@ -72,4 +74,18 @@ export function updateProjectConfig(tree: Tree, schema: Schema) {
};

updateProjectConfiguration(tree, schema.project, projectConfig);

const workspaceConfig = readWorkspaceConfiguration(tree);
if (
workspaceConfig.tasksRunnerOptions?.default &&
!workspaceConfig.tasksRunnerOptions.default.options.cacheableOperations[
'server'
]
) {
workspaceConfig.tasksRunnerOptions.default.options.cacheableOperations = [
...workspaceConfig.tasksRunnerOptions.default.options.cacheableOperations,
'server',
];
updateWorkspaceConfiguration(tree, workspaceConfig);
}
}
18 changes: 18 additions & 0 deletions packages/angular/src/generators/setup-ssr/setup-ssr.spec.ts
@@ -1,4 +1,5 @@
import {
NxJsonConfiguration,
readJson,
readProjectConfiguration,
updateProjectConfiguration,
Expand Down Expand Up @@ -130,6 +131,23 @@ describe('setupSSR', () => {
for (const [dep, version] of Object.entries(devDeps)) {
expect(packageJson.devDependencies[dep]).toEqual(version);
}
const nxJson = readJson<NxJsonConfiguration>(tree, 'nx.json');
expect(nxJson.tasksRunnerOptions).toMatchInlineSnapshot(`
Object {
"default": Object {
"options": Object {
"cacheableOperations": Array [
"build",
"lint",
"test",
"e2e",
"server",
],
},
"runner": "nx/tasks-runners/default",
},
}
`);
});

it('should use fileReplacements if they already exist', async () => {
Expand Down

0 comments on commit 61dd390

Please sign in to comment.