diff --git a/packages/schematics/angular/application/index.ts b/packages/schematics/angular/application/index.ts index cac60c23177b..969dc08ff70c 100644 --- a/packages/schematics/angular/application/index.ts +++ b/packages/schematics/angular/application/index.ts @@ -420,6 +420,8 @@ function getComponentOptions(options: ApplicationOptions): Partial { + config.schematics = { + '@schematics/angular:component': { type: 'component' }, + }; + }); + + for (const style of ['2025', '2016']) { + const project = `app-${style}`; + const appPath = `projects/${project}/src/app`; + const componentName = style === '2016' ? 'app.component' : 'app'; + + await ng( + 'generate', + 'application', + project, + `--file-name-style-guide=${style}`, + '--style=css', + '--ssr=false', + '--skip-install', + ); + await ng('build', project, '--configuration=development'); + await expectFileToMatch(`${appPath}/${componentName}.ts`, `styleUrl: './${componentName}.css'`); + await expectFileNotToExist(`${appPath}/${style === '2016' ? 'app' : 'app.component'}.ts`); + } + + // Ordinary component generation should still use the workspace default. + await ng('generate', 'component', 'example', '--project=app-2025', '--skip-tests'); + await expectFileToMatch('projects/app-2025/src/app/example/example.component.ts', 'export class'); +}