diff --git a/src/schematics/ng-add/index.spec.ts b/src/schematics/ng-add/index.spec.ts index 28ba023..0e61436 100644 --- a/src/schematics/ng-add/index.spec.ts +++ b/src/schematics/ng-add/index.spec.ts @@ -71,13 +71,18 @@ describe('ng-add', () => { const angularJSON = JSON.parse(getFileContent(tree, '/angular.json')); const ssApp = angularJSON.projects['ss-angular-cli-app']; expect(ssApp.architect['single-spa']).toBeDefined(); - expect(ssApp.architect['single-spa'].builder).toBe('single-spa-angular:build'); + expect(ssApp.architect['single-spa'].builder).toBe('single-spa-angular:build'); expect(ssApp.architect['single-spa'].options.main).toBe('src/main.single-spa.ts'); + expect(ssApp.architect['single-spa-serve']).toBeDefined(); + expect(ssApp.architect['single-spa-serve'].builder).toBe('single-spa-angular:dev-server'); + expect(ssApp.architect['single-spa-serve'].options.browserTarget).toBe('ss-angular-cli-app:single-spa'); + }); test('should add build:single-spa npm script', () => { const tree = testRunner.runSchematic('ng-add', { routing: true }, defaultAppTree); const packageJSON = JSON.parse(getFileContent(tree, '/package.json')); expect(packageJSON.scripts['build:single-spa']).toBeDefined(); + expect(packageJSON.scripts['serve:single-spa']).toBeDefined(); }); }); diff --git a/src/schematics/ng-add/index.ts b/src/schematics/ng-add/index.ts index 9ab00f3..d0f09e8 100644 --- a/src/schematics/ng-add/index.ts +++ b/src/schematics/ng-add/index.ts @@ -72,6 +72,10 @@ export function updateConfiguration(options: NgAddOptions) { clientProject.architect['single-spa'].builder = 'single-spa-angular:build'; clientProject.architect['single-spa'].options.main = 'src/main.single-spa.ts'; + // Copy configuration from the serve architect + clientProject.architect['single-spa-serve'] = clientProject.architect.serve; + clientProject.architect['single-spa-serve'].builder = 'single-spa-angular:dev-server'; + clientProject.architect['single-spa-serve'].options.browserTarget = `${project.name}:single-spa`; host.overwrite(workspacePath, JSON.stringify(workspace, null, 2)); @@ -93,6 +97,8 @@ export function addNPMScripts(options: NgAddOptions) { pkg.scripts['build:single-spa'] = `ng run ${options.project}:single-spa`; + pkg.scripts['serve:single-spa'] = `ng run ${options.project}:single-spa-serve` + host.overwrite(pkgPath, JSON.stringify(pkg, null, 2)); }; }