Placing this function into your theme or even in a plugin means that you can easily add a stylesheet for any WordPress block, core or otherwise.
Once the code is in place, you can simply add a stylesshet into the active theme in the /assets/blocks/
folder. The name of the file must block name with any forward slashes replaced with a hyphen.
For example, to ensure a custom stylesheet is loaded for the core heading block, create a stylsheet named core-heading.css
and place it in the /assets/blocks/
folder in your theme. This stylesheet will then get enqueued.