Skip to content

Instantly share code, notes, and snippets.

@Steve-Reid
Last active December 16, 2022 13:04
Show Gist options
  • Select an option

  • Save Steve-Reid/9e97127f6f5ab4c1e9f8cc65223ca97a to your computer and use it in GitHub Desktop.

Select an option

Save Steve-Reid/9e97127f6f5ab4c1e9f8cc65223ca97a to your computer and use it in GitHub Desktop.
Plop.js Generator Config files
export default function (
/** @type {import('plop').NodePlopAPI} */
plop
) {
// create your generators here
plop.setGenerator('component', {
description: 'Create a component',
prompts: [
{
type: 'input',
name: 'name',
message: 'Components name:',
},
],
actions: [
{
type: 'add',
path: 'src/components/{{pascalCase name}}/{{pascalCase name}}.tsx',
templateFile: 'templates/component.template.hbs',
},
{
type: 'add',
path: 'src/components/{{pascalCase name}}/index.tsx',
templateFile: 'templates/index.template.hbs',
},
],
});
plop.setGenerator('page', {
description: 'Create a page',
prompts: [
{
type: 'input',
name: 'name',
message: 'Page name:',
},
],
actions: [
{
type: 'add',
path: 'src/pages/{{pascalCase name}}/{{pascalCase name}}.tsx',
templateFile: 'templates/component.template.hbs',
},
],
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment