-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Adds import statements for the stylesheet files #53639
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
Adds import statements for the stylesheet files #53639
Conversation
t-hamano
left a comment
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.
Thanks for the PR!
I read the tutorial on this page. The tutorial appears to enqueue the CSS files created in the plugin root directory via block.json, as described in the "Enqueue stylesheets" section.
Therefore, I think it will work without the import statement.
|
Thanks @t-hamano, my experience was that it didn't work without the import statements. I'll test again. |
|
My recollection is that without the import statements the build process didn't add the CSS files to the |
This is true. However, this tutorial appears to expect users to create their own CSS files in the plugin root directory.
My understanding is that this tutorial expects the following directory structure: If this is correct, then the sample code in block.json appears to be incorrect. {
"apiVersion": 3,
"name": "gutenberg-examples/example-02-stylesheets",
"title": "Example: Stylesheets",
"icon": "universal-access-alt",
"category": "layout",
"editorScript": "file:./block.js",
"editorStyle": "file:./editor.css",
"style": "file:./style.css"
}Only the editorScript path should refer to the build directory: {
"apiVersion": 3,
"name": "gutenberg-examples/example-02-stylesheets",
"title": "Example: Stylesheets",
"icon": "universal-access-alt",
"category": "layout",
"editorScript": "file:./build/block.js",
"editorStyle": "file:./editor.css",
"style": "file:./style.css"
}This tutorial might be confusing because it differs from the file structure created by create-block. |
|
@t-hamano I just tested again with the CSS files in the project root, and you're right. The CSS files are picked up without the import statements. What I didn't notice the first time I ran through the tutorial is that the block name gets changed in the second lesson. I'll close this and create another PR to draw attention to the name change. I'm also thinking of creating a PR to add a section to the first lesson with steps for:
as those steps are not explicit. What do you think? |
I think this is a great idea. Since a method of development using the create-block package already exists, I think this page should be intended to manually build a basic block development environment without using create-block. Therefore, mentioning npm is a good thing, but since this page can also contain plain code samples that do not use JSX (and do not require a build), it may be necessary to provide explanations that address both cases. For example, the following:
|
That's awesome - you've virtually written it for me 😅! Thanks @t-hamano I'll get that PR together. |
What?
Adds import statements for the stylesheet files in the JSX example for adding a block classname, in the "Use styles and stylesheets" page of the Block tutorial.
Why?
The example doesn't work without them.