From b563cea0bb081f9506d88753f7dfaf070aa186b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Zi=C3=B3=C5=82kowski?= Date: Mon, 31 Jan 2022 12:25:04 +0100 Subject: [PATCH] Scripts: Fallback to `src/index.js` when no valid scripts in metadata for `build` command (#38367) * Scripts: Fallback to `src/index.js` when no valid scripts in metadata for `build` command * Scripts: Add CHANGELOG entry --- packages/scripts/CHANGELOG.md | 3 ++- packages/scripts/utils/config.js | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/scripts/CHANGELOG.md b/packages/scripts/CHANGELOG.md index 9b863bd17f7bd..b31861ddfc5b4 100644 --- a/packages/scripts/CHANGELOG.md +++ b/packages/scripts/CHANGELOG.md @@ -6,7 +6,8 @@ ### Bug Fix -- Fix the `build` command that does not generate assets on Windows OS [#38348](https://github.com/WordPress/gutenberg/pull/38348). +- Fix the `build` command that does not generate assets on Windows OS ([#38348](https://github.com/WordPress/gutenberg/pull/38348)). +- Adds fallback to `src/index.js` when no valid scripts discovered in metadata files when running the `build` command ([#38367](https://github.com/WordPress/gutenberg/pull/38367)). ## 20.0.1 (2022-01-28) diff --git a/packages/scripts/utils/config.js b/packages/scripts/utils/config.js index 8ec4d538fafcc..c61cfbcb6fef5 100644 --- a/packages/scripts/utils/config.js +++ b/packages/scripts/utils/config.js @@ -188,7 +188,7 @@ function getWebpackEntryPoints() { } ); if ( blockMetadataFiles.length > 0 ) { - return blockMetadataFiles.reduce( + const entryPoints = blockMetadataFiles.reduce( ( accumulator, blockMetadataFile ) => { const { editorScript, @@ -227,6 +227,10 @@ function getWebpackEntryPoints() { }, {} ); + + if ( Object.keys( entryPoints ).length > 0 ) { + return entryPoints; + } } // 3. Checks whether a standard file name can be detected in the `src` directory,