plopfile.js 1011 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const config = require('./config.json')
  2. module.exports = function (plop) {
  3. plop.setGenerator('controller', {
  4. description: '生成新页面',
  5. prompts: [
  6. {
  7. type: 'input',
  8. name: 'path',
  9. message: '请输入页面路径',
  10. },
  11. {
  12. type: 'input',
  13. name: 'title',
  14. message: '请输入页面标题',
  15. default: config.VITE_APP_TITLE,
  16. },
  17. ],
  18. actions: [
  19. {
  20. type: 'add',
  21. path: 'page/{{path}}.html',
  22. templateFile: 'plop-template/index.html.hbs',
  23. },
  24. {
  25. type: 'add',
  26. path: 'page/{{path}}.js',
  27. templateFile: 'plop-template/index.js.hbs',
  28. },
  29. {
  30. type: 'add',
  31. path: 'src/views/{{path}}/index.vue',
  32. templateFile: 'plop-template/index.vue.hbs',
  33. },
  34. {
  35. type: 'append',
  36. path: 'index.html',
  37. pattern: '<body>',
  38. template: "<a target='_blank' href='page/{{path}}.html'>{{path}}</a>",
  39. },
  40. ],
  41. })
  42. }