This is a Visual Studio Code extension that helps in generating new blocks for your projects.
Features
Generate new blocks with a simple command.
Automatically modifies register-blocks.php to include the new block.
Generates a JSON template for the new block.
Requirements
Visual Studio Code
Node.js
Installation
Clone this repository.
Run npm install in the project root.
Open the project in Visual Studio Code.
Press F5 to start the extension.
Usage
Run the command Generate new block from the command palette (Ctrl+Shift+P or Cmd+Shift+P on Mac) to generate a new block.
Extension Settings
This extension contributes the following settings:
js-block-generator.acfRegisterFunctionName: The name of the function that registers the block inside the register-blocks.php file (default: "acf_register_block").
js-block-generator.acfAllowedBlockTypes: The name of the function that sets allowed block types inside the register-blocks.php file (default: "sb_allowed_block_types").
js-block-generator.blockPath: The path where new blocks should be created (default: "./blocks").
js-block-generator.createScssFolder: Whether the extension should create a SCSS folder (default: false).
js-block-generator.acfEnqueueStyles: Whether the extension should create a SCSS folder (default: false).
js-block-generator.modifyEnqueueStylesFunctionName: The name of the function that enqueue block styles inside the register-blocks.php file (default: "sb_enqueue_block_styles").
Known Issues
register-blocks.php file must exist in the inc directory of the root path.