@@ -25,6 +25,7 @@ export type TemplateComponentSchema = {
2525 flat ?: boolean ;
2626 type : string ;
2727 isPageModule : boolean ;
28+ isLayout : boolean ;
2829 route ?: string ;
2930 routeKey ?: string ;
3031 routesFilePath ?:string ;
@@ -87,6 +88,7 @@ export function generateComponentTemplate(
8788 templateSources . push ( mergeWith ( subTemplateSource , MergeStrategy . Overwrite ) ) ;
8889 }
8990
91+
9092 let routingModulePath : Path | undefined ;
9193
9294 if ( options . route ) {
@@ -95,6 +97,18 @@ export function generateComponentTemplate(
9597 options . isPageModule = true
9698 }
9799
100+ let appIntegration = noop ( )
101+ if ( options . isPageModule ) {
102+ appIntegration = modifyAppToAddNewPage ( options )
103+ }
104+ else if ( options . isLayout ) {
105+ appIntegration = ( tree : Tree ) => {
106+ applyAdditionalAppFeaturesForNewComponent ( options , tree ) ;
107+ }
108+ }
109+ else if ( ! options . isLayout ) {
110+ appIntegration = addDeclarationToModuleCpntsArr ( options )
111+ }
98112 return chain ( [
99113 externalSchematic ( '@schematics/angular' , 'component' , {
100114 name : options . name ,
@@ -103,17 +117,16 @@ export function generateComponentTemplate(
103117 project : options . project ,
104118 style : 'scss' ,
105119 skipImport : ! options . isPageModule ,
120+ // skipImport:true,
106121 module :options . module
107122 } ) ,
108123 options . route && options . standalone ? addRouteDeclarationToNgModule ( options , routingModulePath , "component" ) : noop ( ) ,
109- options . isPageModule
110- ? modifyAppToAddNewPage ( options )
111- : addDeclarationToModuleCpntsArr ( options ) ,
112- ...templateSources ,
113- ( tree : Tree , _context : SchematicContext ) => {
114- excludeSubFolders ( options , tree , _context ) ;
115- return tree ;
116- }
124+ appIntegration ,
125+ ...templateSources ,
126+ ( tree : Tree , _context : SchematicContext ) => {
127+ excludeSubFolders ( options , tree , _context ) ;
128+ return tree ;
129+ }
117130
118131 ] )
119132 }
@@ -192,12 +205,7 @@ function addDeclarationToModuleCpntsArr(options: TemplateComponentSchema) {
192205 // add import path
193206 addTsImportPath ( options , modulePath , changes , moduleFile , componentVar , tree ) ;
194207
195-
196-
197- // add scss
198- addScssToAppStyles ( options , tree ) ;
199-
200- updateIdPrefixObj ( options , tree )
208+ applyAdditionalAppFeaturesForNewComponent ( options , tree ) ;
201209 return tree ;
202210 } ;
203211}
@@ -305,6 +313,12 @@ let addRouteEntryToEnvArr = (options: TemplateComponentSchema, tree: Tree) => {
305313 }
306314} ;
307315
316+ function applyAdditionalAppFeaturesForNewComponent ( options : TemplateComponentSchema , tree :Tree ) {
317+ addScssToAppStyles ( options , tree ) ;
318+
319+ updateIdPrefixObj ( options , tree ) ;
320+ }
321+
308322function addScssToAppStyles ( options : TemplateComponentSchema , tree : Tree ) {
309323 try {
310324 let filePath = getFilePath ( options ) ;
0 commit comments