Skip to content

Commit

Permalink
Add clarification about importing css/scss files (#61252)
Browse files Browse the repository at this point in the history
* Add clarification about importing css/scss files

* Wrap in callout and update phrasing for WP scripts

* Fix type in Block Tutorial Styles doc
  • Loading branch information
colorful-tones authored Aug 7, 2024
1 parent 4b25473 commit ddadd1a
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ And a `style.css` file to load on the frontend:

The files will automatically be enqueued when specified in the block.json.

<div class="callout callout-info">

If you are using `@wordpress/scripts` you will need to import your stylesheet within your corresponding JavaScript file in order for `@wordpress/scripts` to process the stylesheet.

Example:

- In `edit.js` you would place `import './editor.scss';`
- In `index.js` you would place `import './style.scss';`
- In `view.js` you would place `import './view.scss';` (interactive block template)
</div>

**Note:** If you have multiple files to include, you can use standard `wp_enqueue_style` functions like any other plugin or theme. You will want to use the following hooks for the block editor:

- `enqueue_block_editor_assets` - to load only in editor view
Expand Down

0 comments on commit ddadd1a

Please sign in to comment.