首页 > 其他 > 详细

plop 使用

时间:2020-08-05 12:12:06      阅读:91      评论:0      收藏:0      [点我收藏+]

plop 使用的步骤

  - yarn add plop --dev 将plop安装到项目中   
  - 在项目根目录创建plopfile.js文件
  - 在plopfile.js定义脚手架任务
  - 编写模板文件
  - yarn plop component //用自定义的生成器运行脚手架任务

技术分享图片

plopfile.js

module.exports = plop => {
    plop.setGenerator(‘component‘, {//这里定义生成器的名字component
      description: ‘application component‘,
      prompts: [
        {
          type: ‘input‘,
          name: ‘name‘,
          message: ‘component name‘
        }
      ],
      actions: [
        {
          type: ‘add‘,//代表添加文件
          path: ‘src/components/{{name}}/{{name}}.vue‘,//生成文件的地址
          templateFile: ‘plop-templates/component.js.hbs‘//添加的模板
        },
        {
          type: ‘add‘,
          path: ‘src/components/{{name}}/{{name}}.css‘,
          templateFile: ‘plop-templates/component.css.hbs‘
        },
        {
          type: ‘add‘,
          path: ‘src/components/{{name}}/{{name}}.test.js‘,
          templateFile: ‘plop-templates/component.test.js.hbs‘
        }
      ]
    })
  }

plop 使用

原文:https://www.cnblogs.com/zhuzy/p/13438538.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!