“This is the 18th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021”
preface
Sometimes, we don’t need to create a complete project structure, maybe we just need to create certain types of files on a project basis, for example:
- We create certain types of base files from an existing project: Eslint, Babel, etc
It might be a bit of a problem to configure these configurations directly, so we can use the methods provided by Yeoman to do some of these configurations
Sub Generator
Here we can do some configuration using the CLI provided with generator-Node
Command:
yo node:cli
Copy the code
After entering the command, we select Yes
After that, we’ll create a lib folder +package.json
The file structure is as follows
Let’s go back to the file
We found that package.json already has the configuration
{
"bin": "lib/cli.js"."dependencies": {
"meow": "^ 3.7.0"
},
"devDependencies": {
"lec": "^" 1.0.1
},
"scripts": {
"prepare": "lec lib/cli.js -c LF"}}Copy the code
With this we can use these global modules
General procedure
- Identify your needs
- Find the right one
Generator
- Global scope installation found
Generator
- through
yo
Run the correspondingGenerator
- Enter options through the command line interactively
- Generate the project structure you need
For example
- We are going to create a web application:
- So let’s go in here
YEOMAN
Website:YEOMAN - search
web app
- Installation:
npm install --global yo gulp-cli generator-webapp
- Once installed, we can go through
YEOMAN
Run theyo webapp
- After that, some options will appear, such as whether you want to use Sass or not, and you can make some choices based on what you want to use
- Finally, we have the basic structure of a Web project
A digression
Here are some things to note: Using the generator project, his generator is dependent on some c + + module, these modules need to be at the time of installation need to download some binary files, it will lead to our installation is slow, but if you have a good result of NPM, you should know that we can go to set up some corresponding mirror to accelerate, Here we provide some configuration files