Skip to content
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

Fix include viewStyle assets in dynamic version generation #436

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nervous-berries-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"10up-toolkit": patch
---

Fix include `viewStyle` assets in dynamic version generation
6 changes: 4 additions & 2 deletions packages/toolkit/utils/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ const transformBlockJson = (content, absoluteFilename) => {
return content;
}
const metadata = JSON.parse(rawMetadata);
const { version, style } = metadata;
const { version, style = [], viewStyle = [] } = metadata;

const styleArray = Array.isArray(style) ? style : [style];
const viewStyleArray = Array.isArray(viewStyle) ? viewStyle : [viewStyle];
const combinedStylesArray = [...styleArray, ...viewStyleArray];

// check whether the style property is defined and a local file path
const isFilePath = styleArray?.some((styleName) => styleName?.startsWith('file:'));
Expand All @@ -71,7 +73,7 @@ const transformBlockJson = (content, absoluteFilename) => {
let styleFileContentHash = '';

if (!hasVersion && isFilePath) {
styleArray.forEach((rawStylePath) => {
combinedStylesArray.forEach((rawStylePath) => {
if (!rawStylePath.startsWith('file:')) {
return;
}
Expand Down
Loading