[resolved] the problem that custom directories cannot be copied in vue-cli3 custom preset

Business background

  • vue-cli3 some of the official predefined templates cannot meet their needs
  • for example, I have common tool libraries, sass styles, and generic ui components that need to be built into templates
  • so configure preset yourself.

problems encountered

  • the official document says that the render function in generator.js can generate the specified file into the project
  • but I wrote
  • with reference to the official example
  • the final generated project does not contain some of my preset files
  • that is, none of the files under the template directory have been copied

the following is the project file

t/preset.json
{
  "plugins": {}
}
t/generator.js
module.exports = api => {
  console.log(123123123123);
  api.render("./template");
};
t/template
- src
  - layouts
    - test.js
  - test.js
- test.js

troubleshooting

  • there is an output of 123123123123 at the terminal, indicating that generator is executed
Jun.13,2022

empty folders and empty files will not be render in the past

.
  • all the test.js I created are empty files
  • so it was not compiled.
Menu