diff --git a/apps/electron-backend-e2e/src/performance/performance-build-config.spec.ts b/apps/electron-backend-e2e/src/performance/performance-build-config.spec.ts index c333d54ab..33f81351b 100644 --- a/apps/electron-backend-e2e/src/performance/performance-build-config.spec.ts +++ b/apps/electron-backend-e2e/src/performance/performance-build-config.spec.ts @@ -1,5 +1,6 @@ /* eslint-disable playwright/expect-expect -- These are Node assertion-based configuration contract tests. */ import assert from 'node:assert/strict'; +import { execFileSync } from 'node:child_process'; import { readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import test from 'node:test'; @@ -16,6 +17,20 @@ interface ProjectConfiguration { targets: Record; } +interface NxGraphTask { + outputs?: string[]; + target: { + project: string; + target: string; + }; +} + +interface NxGraph { + tasks: { + tasks: Record; + }; +} + const workspaceRoot = fileURLToPath(new URL('../../../../', import.meta.url)); function readProject(relativePath: string): ProjectConfiguration { @@ -24,6 +39,37 @@ function readProject(relativePath: string): ProjectConfiguration { ) as ProjectConfiguration; } +function readResolvedWebBuildTask(): NxGraphTask | undefined { + const environment = { + ...process.env, + FORCE_COLOR: '0', + NX_DAEMON: 'false', + }; + delete environment['NO_COLOR']; + + const graph = JSON.parse( + execFileSync( + process.execPath, + [ + join(workspaceRoot, 'node_modules/nx/dist/bin/nx.js'), + 'run', + 'web:build', + '--graph=stdout', + ], + { + cwd: workspaceRoot, + encoding: 'utf8', + env: environment, + } + ) + ) as NxGraph; + + return Object.values(graph.tasks.tasks).find( + (task) => + task.target.project === 'web' && task.target.target === 'build' + ); +} + const e2eProject = readProject('apps/electron-backend-e2e/project.json'); const electronProject = readProject('apps/electron-backend/project.json'); const remoteControlProject = readProject( @@ -64,6 +110,13 @@ test('the web performance build keeps production renderer behavior with profilin assert.equal(performance['sourceMap'], true); }); +test('the resolved web build cache output is the renderer directory', () => { + const task = readResolvedWebBuildTask(); + + assert.ok(task, 'the Nx graph must include web:build'); + assert.deepEqual(task.outputs, ['dist/apps/web']); +}); + test('the remote-control performance build keeps optimized hashed output with profiling source maps', () => { const build = remoteControlProject.targets['build']; const production = build.configurations?.['production']; diff --git a/apps/web/project.json b/apps/web/project.json index 3fb7392b3..302ea2e37 100644 --- a/apps/web/project.json +++ b/apps/web/project.json @@ -13,7 +13,7 @@ "targets": { "build": { "executor": "@angular/build:application", - "outputs": ["{options.outputPath}"], + "outputs": ["{workspaceRoot}/dist/apps/web"], "options": { "outputPath": { "base": "dist/apps/web",