Opened 13 months ago
#60163 new enhancement
Block editor admin assets should use asset file version when in debug/local mode
Reported by: | helgatheviking | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Script Loader | Keywords: | |
Focuses: | Cc: |
Description
Admin assets defined in block.json are enqueued in the editor with the version property from block.json of if not defined, the version of WordPress. [source](https://github.com/WordPress/wordpress-develop/blob/455044e6261e64970fb9039dba52ceb47290a634/src/wp-includes/blocks.php#L273)
That's fine for plugin release, but for development it means you can build a block using the [create block script](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/), run npm run start
and the editor style assets get compiled correctly as you work but the browser keeps showing the cached version stylesheet. Editor scripts however, [pull a version from the index.asset.php
](https://github.com/WordPress/wordpress-develop/blob/455044e6261e64970fb9039dba52ceb47290a634/src/wp-includes/blocks.php#L194) so it's always refreshed on page reload.
I'd love to see the order go something like:
If dev mode (either WP_DEVELOPMENT_MODE
or WP_ENVIRONMENT_TYPE
constants then use the version of index.asset.php
.
If not dev mode, use the version from the block.json file.
Finally, default to the version of WordPress.