-
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: Allow custom folder name for a block #37612
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gziolo
added
[Tool] Create Block
/packages/create-block
[Type] Enhancement
A suggestion for improvement.
labels
Dec 23, 2021
gziolo
commented
Dec 23, 2021
Size Change: 0 B Total Size: 1.13 MB ℹ️ View Unchanged
|
gziolo
force-pushed
the
update/create-block-custom-block-path
branch
7 times, most recently
from
December 29, 2021 15:42
c9fd4b2
to
100338c
Compare
gziolo
added
[Tool] WP Scripts
/packages/scripts
and removed
[Status] In Progress
Tracking issues with work in progress
labels
Dec 29, 2021
gziolo
force-pushed
the
update/create-block-custom-block-path
branch
from
December 30, 2021 07:06
100338c
to
4454f24
Compare
gziolo
requested review from
ajitbohra,
mkaz,
nerrad and
ntwb
as code owners
December 30, 2021 07:21
gziolo
added
the
Developer Experience
Ideas about improving block and theme developer experience
label
Dec 30, 2021
4 tasks
gziolo
force-pushed
the
update/create-block-custom-block-path
branch
from
January 11, 2022 08:33
4454f24
to
c73dba2
Compare
I rebased this branch with the latest changes applied in |
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Developer Experience
Ideas about improving block and theme developer experience
[Tool] Create Block
/packages/create-block
[Tool] WP Scripts
/packages/scripts
[Type] Enhancement
A suggestion for improvement.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Partially addresses #25188.
You can watch two screencasts that contain an extended explanation or read the shorter version that is included afterwards:
create-block-enhancements-1.mov
create-block-enhancements-2.mov
It's an initial version that allows moving
block.json
to any location inside the project rather than having it always in the top-level folder. It will make it possible to handle multipleblock.json
files if users want to scaffold multiple blocks in one plugin.Changes included:
blockTemplatesPath
field in the external template configuration.folderName
for setting the location for theblock.json
file and other optional block files generated from block templates included in the folder set with theblockTemplatesPath
setting.block.json
files located in thesrc
folder and its subfolders to the output folder (build
by default) when usingstart
andbuild
from@wordpress/scripts
.All the above combined allows to put
block.json
in a custom location. When the block metadata is discovered in thesrc
folder (or subfolders) it gets copied to the build folder, which allows using simplified paths for block assets:In addition to that, we can now explicitly set templates related only to the block with
blockTemplatesPath
. The last missing piece that I believe should be tackled separately is to enhance the CLI to support prompts for multiple blocks that would use block templates with customized settings for every block based on the user input.How has this been tested?
Scaffolding
I generated three blocks using templates included in Gutenberg
ES5
ESNext + JSX (the default)
Gutenpride (handbook tutorial)
WordPress environment
I used
wp-env
command integrated with the Gutenberg project.I created an override to the existing config:
File:
.wp-env.override.json
I executed:
Testing plugins
I opened the following URL to test all the installed plugins: http://localhost:8888/wp-admin.
I created a new post and inserter all 3 blocks:
I saved the post and confirmed it renders correctly on the frontend.
Screenshots
Editor:
Frontend:
Types of changes
New features and enhancements (non-breaking change which adds functionality) -->
Checklist:
*.native.js
files for terms that need renaming or removal).