Skip to content

Documentation: Fix missing CSS import in data basics tutorial code #69914

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

Merged

Conversation

im3dabasia
Copy link
Contributor

What?

Closes: No issue (Small doc fix)

Why?

The current code example in the data basics tutorial is missing the necessary CSS import statement in index.js, which prevents the styles from being included in the build process. Without this import, the style-index.css file isn't generated in the build directory, causing the PHP enqueue statement to reference a non-existent file.

How?

Add the CSS import line to the index.js code example in the tutorial documentation. This ensures that when users follow the tutorial and run the build process, the CSS file will be properly processed and available for the PHP code to enqueue.

Testing Instructions

  1. Follow the tutorial steps to create the plugin Link
  2. Run npm start to build the plugin
  3. Verify that the build/style-index.css file is created
  4. Activate the plugin in WordPress
  5. Navigate to the "My first Gutenberg app" page

Screenshots or screencast

Screen.Recording.2025-04-16.at.4.45.46.PM.mov

Copy link

github-actions bot commented Apr 16, 2025

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka Mamaduka added the [Type] Developer Documentation Documentation for developers label Apr 16, 2025
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@t-hamano t-hamano added the props-bot Adding this label triggers the Props Bot workflow for a PR. label Apr 17, 2025
@github-actions github-actions bot removed the props-bot Adding this label triggers the Props Bot workflow for a PR. label Apr 17, 2025
@t-hamano t-hamano merged commit 75bafad into WordPress:trunk Apr 17, 2025
66 of 70 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.8 milestone Apr 17, 2025
@merijnponzo
Copy link

Can someone explain ..

Whenever you change
"style": "file:./style-index.css",

in your src/block/block.json

https://developer.wordpress.org/block-editor/getting-started/tutorial/

it still generated as style-index.css

i believe because style.css is imported in index.js and generated as style-index.js

but it doesnt feel very logical what happens here. I guess whatever the name in block.json is for style: "" should be generated in the dist folder

@t-hamano
Copy link
Contributor

@merijnponzo

but it doesnt feel very logical what happens here. I guess whatever the name in block.json is for style: "" should be generated in the dist folder

Can you please elaborate a bit on what you're seeing as the problem?

  • There are options to change the output directory (--output-path).
  • You can add your own webpack.config.js.
  • You can also use Sass directly and build only the style files individually.

chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants