First, the concept of scaffolding
Scaffolding is the integration of front-end engineering and the initiator of front-end engineering. Its essence and function is to create project infrastructure and provide project specifications and conventions.
Second, general tools
Yeoman versatile scaffold tool is easy to expand and flexible enough to create your own scaffold. During Plop project development, specific types of files are created.
Iii. Basic use of Yeoman
4. Yeoman Sub Generator
Yo node:cli // yarn // yarn link // chen-module –help In the current file
5. Basic steps to use Yeoman
Create a custom generator module
Nature: The custom generator is essentially an NPM module
Methods:
1. Yarn init Initialize the package.json file
2. Yarn Add Yeoman-generator Import module
/ / generators/app/index.js/generators/app/index.js
** 4. Document content **
5. Yarn Link global
6. Create a folder and run yo sample
Note: at that time, the eoman-generator version is 5. Requires Yeoman -environment at least 3.0.0,current version is 2.10.3,try reinstalling latest version of “ofIt is best to specify the version of yeoman-generator as 4.0.1. “Yeoman-generator “: “^4.0.1” is best
7. Templates can also be used to create files in a specified directory
Enclosing the fs. CopyTpl (TMPL, the output, the context). Take three parameters
8. Accept user instructions and generate relevant templates
Nine, batch generation of multiple project files method
Creates an array of file paths, looping over each file
Publish a custom generator module to NPM
SQL > create local repository;
Create gitignore file echo node_module >. Gitigonre
(2) Git init
(3)git add .
(4)git commit -m ‘fistcomit’
Git remote add origin
Git push -u origin master
2. Package and compile
Yarn publish –registry=registry.yarnpkg.com yarn publish — registry.yarnpkg.com
Error error Couldn’t publish package:……. invalid for new packages.
The red box is lower case. All NPM packages are required to have lower case. Therefore, the project is changed to generator-Chen-react-com
(3) may also be an error r Couldn ‘t publish package: “registry.yarnpkg.com/generator-c… Go to your email and activate the email from NPM with the click of a button.