-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Block: Optimize the default template for multiple blocks case #68175
base: trunk
Are you sure you want to change the base?
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
@@ -59,6 +59,7 @@ const predefinedPluginTemplates = { | |||
}, | |||
viewScript: 'file:./view.js', | |||
example: {}, | |||
folderName: './src/$slug', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified that only for the default templates bundled with the package instead of for every project template, as I'm not entirely sure what implications it would have for developer docs. @ndiego, do you forsee any complications?
Size Change: 0 B Total Size: 1.84 MB ℹ️ View Unchanged
|
Flaky tests detected in a499ab2. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12429700727
|
What?
Related to #25188.
@ryanwelcher explores a variant of the template that automatically supports multiple blocks in the single plugin:
Here, I propose updating the default template to scaffold a block in its subfolder named after the block's slug to make it easier to update to multiple blocks in a single plugin.
Why?
When a developer needs to add more than one block in a WordPress plugin scaffolder by
npx @wordpress/create-block
they often need to move the first block to a subfolder and update the path in PHP file accordingly.How?
The default path to the block can be extended to contain the block's slug as the folder name.
Testing Instructions
Testing Instructions for Keyboard
Run
npm run test:create-block
and make sure the tests pass.Scaffold a block and inspect the project:
Ensure that the block still works as before in the block editor.