As a small tool for front-end engineering, PLOP is more similar to Yeoman’s Sub Generator module, which dynamically generates similar project files in batches on the basis of the original project. Plop is more convenient and simple to use, and the configuration of import files is similar to that of Yeoman. Here is a simple way to use it. Generate the base project code from the original React project base file.

Install plop dependencies for a React base project

yarn add plop --dev
Copy the code

2. Create the plopfile.js entry file under the root directory of the project and write the following.

Write your own code in the template file according to your own needs. For example, as shown in the figure, you can use {{}} to dynamically modify some values. The value of name is the value entered by the user.

4. Run the command line and enter the information as prompted

yarn plop 'chenCom' // The project name of your ploPEnter the command line prompt to generate the corresponding fileCopy the code