首页 > 解决方案 > 是否可以在 PLOP 中使用单个 templateFile 添加多个文件

问题描述

我正在使用 plop 依赖来生成模块。我想一次性生成 n 个使用单个模板的文件。

plop.setGenerator('module', {
  description: 'Create a module',
  // User input prompts provided as arguments to the template
  prompts: [
    {
      // Raw text input
      type: 'input',
      // Variable name for this input
      name: 'name',
      // Prompt to display on command line
      message: 'What is your module name?'
    }
  ],
  actions: [
    {
      // Add a new file
      type: 'addMany',
      // Path for the new file
      destination: 'src/Screens/{{pascalCase name}}',
      // Handlebars template used to generate content of new file
      templateFiles: 'plop-templates/**.js.hbs'
    }
  ]
})

标签: javascriptnode.jsplop

解决方案


将 templateFiles 包装在数组中。

templateFiles: ['plop-templates/**.js.hbs']

推荐阅读