Create WordPress Block
Generates PHP, JS and CSS code for registering a block for a WordPress plugin or theme.

Description
Blocks are the fundamental element of the WordPress block editor. They are the primary way in which plugins and themes can register their own functionality and extend the capabilities of the editor.
Visit the Gutenberg handbook to learn more about Block API.
Usage
The following command generates PHP, JS and CSS code for registering a block.
$ npm init wordpress-block [options] [slug]
[slug] is optional. When provided it triggers the quick mode where it is used as the target location for scaffolded files and the internal block name. The rest of the configuration is set to all default values.
Options:
-t, --template <name> template type name, allowed values: "es5", "esnext" (default: "esnext")
-V, --version output the version number
-h, --help output usage information
Examples:
- Quick start – one command that uses defaults for all options. You just need
to provide the
slug which is the target location for scaffolded files
and the internal block name.
$ npm init wordpress-block todo-list
$ cd todo-list
- Interactive mode - it gives a chance to customize a few most important options.
$ npm init wordpress-block
- ES5 template – it is also possible to pick ES5 template when you don't want
to deal with a build step which enables ESNext and JSX support.
$ npm init --template es5 wordpress-block
When you scaffold a block, you must provide at least a slug name, the namespace
which usually corresponds to either the theme or plugin name, and the category. In most cases,
we recommended pairing blocks with plugins rather than themes, because only using
plugin ensures that all blocks still work when your theme changes.
WP-CLI
Another way of making a developer’s life easier is to use WP-CLI,
which provides a command-line interface for many actions you might perform on
the WordPress instance. One of the commands wp scaffold block was used as
the baseline for this tool and ES5 template in particular.
