1

I can't find how to use a newly created schematics with NX using ng g workspace-schematic <schematic-name>

Here is my structure :

|- tools/
  |- schematics
   |- my-first-schematic
   |- my-second-schematic

I want to use my-first-schematic within my-second-schematic. I know about externalSchematic() but it's useful when we want to call schematif from another collection.

Thanks!

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
KevinTale
  • 1,658
  • 3
  • 25
  • 47

1 Answers1

0

we can directly import my-first-schematic into my-second-schematic and then chain it simply. e.g.

tools/schematics/my-first-schematics/index.ts

export default function(schema: any): Rule {
    console.log('my-first-schematics');
}

tools/schematics/my-second-schematic/index.ts

 import myFirstSchematics from '../my-first-schematics';

 export default function(schema: any): Rule {
     console.log('my-second-schematic');
     ...
     return chain([
         myFirstSchematics(schema),
         ...
     ]);
 }
Pankaj Verma
  • 191
  • 10