Skip to content

Add multiple styles/scripts with dependencies, version, etc. in block.json and provide examples in documentation #53847

@troytempleman

Description

@troytempleman

What problem does this address?

I see on the Metadata in block.json page that its possible to add front end, editor and shared styles/scripts in block.json. I also see you can add multiple scripts for each one of these, even with a mix of file names and previously registered script handles. For example, "style": [ "file:./style.css", "example-shared-style" ]. This is great as it eliminates the need to enqueue these with wp_enqueue_script and wp_enqueue_style in PHP.

However, its not clear to me if you can add an array of dependencies, version, etc. for each script, or if you still have to use wp_enqueue_script/wp_enqueue_style when that is needed. If not, it would be even better to add this option, as each script often have their own dependencies, version, etc. It would also be nice to see an example of how to do that.

What is your proposed solution?

Add the option to add multiple styles/scripts with dependencies, version, etc. in block.json (if not already possible) and provide examples of how to do so on the Metadata in block.json page (or elsewhere).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions