There are two types of generator plugin:
Extension: Web App(Npm Module) = Web App(Npm Module) + Generator Plugin
Custom: New Application(Npm Module) = Web App(Npm Module) + Generator Plugin
In simpler terms, extension means using the original project name of Modern.js, while custom means creating a new name.
The type of generator plugin is provided through the meta
field in package.json
:
For custom type, the type
field supports the custom
value, which utilizes some best practice templates for project development provided by Modern.js, such as .gitignore
, .editorConfig
, etc. Other business-related code templates need to be manually provided through generator plugin.
Generator plugins support using multiple plugins at the same time, which means that multiple --plugin
parameters are supported when executing @modern-js/create
.
For extension generator plugins, when executing with the declared generator plugin parameters, the corresponding lifecycle functions of the project scheme that is extended will be executed in order.
For example, if there are two generator plugins A and B, both of which extend the Modern.js application scheme. A plugin declares to add the a.ts
file, and B plugin declares to add the b.ts
file. When executing npx @modern-js/create@latest --plugin A --plugin B
, and selecting the Web APP scheme, the default project files of the Web APP will be generated first. Then, the A plugin will create the a.ts
file, and then the B plugin will generate the b.ts
file.
For custom generator plugins, only one plugin can be executed at a time. When declaring the --plugin
parameter for @modern-js/create
, a selection option for the scenario of choosing the project scheme will be added after selecting the project scheme, which is the new name defined in the package.json
. Choosing the corresponding generator plugin for the name will execute the corresponding generator plugin logic after the default project scheme is completed. When declaring the --plugin
parameter, the corresponding generator plugin names will be listed one by one for selection in the project scheme scenario.