diff --git a/packages/angular/src/generators/remote/__snapshots__/remote.spec.ts.snap b/packages/angular/src/generators/remote/__snapshots__/remote.spec.ts.snap index 4effca8f98bce..26b2063164a13 100644 --- a/packages/angular/src/generators/remote/__snapshots__/remote.spec.ts.snap +++ b/packages/angular/src/generators/remote/__snapshots__/remote.spec.ts.snap @@ -182,6 +182,26 @@ Object { } `; +exports[`MF Remote App Generator --ssr should generate the correct files 12`] = ` +"import { Route } from '@angular/router'; +import { RemoteEntryComponent } from './entry.component'; + +export const remoteRoutes: Route[] = [{ path: '', component: RemoteEntryComponent }];" +`; + +exports[`MF Remote App Generator --ssr should generate the correct files 13`] = ` +Object { + "dependsOn": Array [ + "build", + "server", + ], + "executor": "nx:run-commands", + "options": Object { + "command": "PORT=4201 node dist/apps/test/server/main.js", + }, +} +`; + exports[`MF Remote App Generator should generate a remote mf app with a host 1`] = ` "const { withModuleFederation } = require('@nrwl/angular/module-federation'); const config = require('./module-federation.config'); diff --git a/packages/angular/src/generators/remote/lib/add-ssr.ts b/packages/angular/src/generators/remote/lib/add-ssr.ts index a63c1bab165cc..f5ac1528fe9a9 100644 --- a/packages/angular/src/generators/remote/lib/add-ssr.ts +++ b/packages/angular/src/generators/remote/lib/add-ssr.ts @@ -50,6 +50,17 @@ export async function addSsr( port, }; + project.targets['static-server'] = { + dependsOn: ['build', 'server'], + executor: 'nx:run-commands', + options: { + command: `PORT=${port} node ${joinPathFragments( + project.targets.server.options.outputPath, + 'main.js' + )}`, + }, + }; + updateProjectConfiguration(tree, appName, project); const installTask = addDependenciesToPackageJson( diff --git a/packages/angular/src/generators/remote/remote.spec.ts b/packages/angular/src/generators/remote/remote.spec.ts index 444b1d377b30e..ed80a03a6d2bf 100644 --- a/packages/angular/src/generators/remote/remote.spec.ts +++ b/packages/angular/src/generators/remote/remote.spec.ts @@ -241,6 +241,10 @@ describe('MF Remote App Generator', () => { tree.read(`apps/test/src/app/remote-entry/entry.routes.ts`, 'utf-8') ).toMatchSnapshot(); expect(project.targets.server).toMatchSnapshot(); + expect( + tree.read(`apps/test/src/app/remote-entry/entry.routes.ts`, 'utf-8') + ).toMatchSnapshot(); + expect(project.targets['static-server']).toMatchSnapshot(); }); }); });