Nx Custom Generator

예시

nx generate @nrwl/nx-plugin:generator my-component
import { Tree, formatFiles, generateFiles } from '@nrwl/devkit';
import * as path from 'path';

export default async function(tree: Tree, schema: any) {
  const templatePath = path.join(__dirname, 'files');
  const destinationPath = `libs/${schema.name}`;

  generateFiles(tree, templatePath, destinationPath, schema);

  await formatFiles(tree);
}
import React from 'react';

interface <%= className %>Props {
  // props here
}

export const <%= className %>: React.FC<<%= className %>Props> = (props) => {
  return (
    <div>
      {/* component content */}
    </div>
  );
};

export default <%= className %>;

nx generate my-component --name=MyNewComponent

혹은 특정 템플릿(보일러플레이트)를 가진 라이브러리를 생성할 수도 있다.