From c239344fef71a5166d50bcb2d88fa3929ade4738 Mon Sep 17 00:00:00 2001 From: Miguel Fonseca <150562+mcsf@users.noreply.github.com> Date: Mon, 26 Jan 2026 16:33:22 +0000 Subject: [PATCH 1/4] Build: Copy Icons manifest file from Gutenberg --- tools/gutenberg/copy-gutenberg-build.js | 26 +++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tools/gutenberg/copy-gutenberg-build.js b/tools/gutenberg/copy-gutenberg-build.js index e5332f806f74a..bbaf7c3440f3c 100644 --- a/tools/gutenberg/copy-gutenberg-build.js +++ b/tools/gutenberg/copy-gutenberg-build.js @@ -98,6 +98,14 @@ const COPY_CONFIG = { { from: 'theme-i18n.json', to: 'theme-i18n.json' }, ], }, + + // Specific files to copy to wp-includes/$destination + wpIncludes: [ + { + files: [ 'packages/icons/src/manifest.php' ], + destination: 'icons', + }, + ], }; /** @@ -982,10 +990,7 @@ async function main() { } } } - } else if ( - entry.isFile() && - entry.name.endsWith( '.js' ) - ) { + } else if ( entry.isFile() && entry.name.endsWith( '.js' ) ) { // Copy root-level JS files const dest = path.join( scriptsDest, entry.name ); fs.mkdirSync( path.dirname( dest ), { recursive: true } ); @@ -1057,6 +1062,19 @@ async function main() { } } + // Copy remaining files to wp-includes + console.log( '\n📦 Copying remaining files to wp-includes...' ); + for ( const fileMap of COPY_CONFIG.wpIncludes ) { + const dest = path.join( wpIncludesDir, fileMap.destination ); + fs.mkdirSync( dest, { recursive: true } ); + for ( const src of fileMap.files ) { + fs.copyFileSync( + path.join( gutenbergDir, src ), + path.join( dest, path.basename( src ) ) + ); + } + } + // 7. Generate script-modules-packages.min.php from individual asset files console.log( '\n📦 Generating script-modules-packages.min.php...' ); generateScriptModulesPackages(); From 4ab0655edd88905baea8b367b8a6afeee966837a Mon Sep 17 00:00:00 2001 From: Miguel Fonseca <150562+mcsf@users.noreply.github.com> Date: Mon, 26 Jan 2026 16:53:49 +0000 Subject: [PATCH 2/4] Copy icon SVGs to wp-includes/icons/library --- tools/gutenberg/copy-gutenberg-build.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tools/gutenberg/copy-gutenberg-build.js b/tools/gutenberg/copy-gutenberg-build.js index bbaf7c3440f3c..125dfafae8c20 100644 --- a/tools/gutenberg/copy-gutenberg-build.js +++ b/tools/gutenberg/copy-gutenberg-build.js @@ -105,6 +105,10 @@ const COPY_CONFIG = { files: [ 'packages/icons/src/manifest.php' ], destination: 'icons', }, + { + files: [ 'packages/icons/src/library/*.svg' ], + destination: 'icons/library', + }, ], }; @@ -1068,10 +1072,17 @@ async function main() { const dest = path.join( wpIncludesDir, fileMap.destination ); fs.mkdirSync( dest, { recursive: true } ); for ( const src of fileMap.files ) { - fs.copyFileSync( - path.join( gutenbergDir, src ), - path.join( dest, path.basename( src ) ) - ); + // Don't run `src` through `glob` unless it contains asterisks, so + // that non-existing files cause errors when calling `copyFile` + const matches = src.includes( '*' ) + ? fs.globSync( path.join( gutenbergDir, src ) ) + : [ path.join( gutenbergDir, src ) ]; + for ( const match of matches ) { + fs.copyFileSync( + match, + path.join( dest, path.basename( match ) ) + ); + } } } From 92cf652578587c18bb158cf1805eefc8dbc3a62a Mon Sep 17 00:00:00 2001 From: Miguel Fonseca <150562+mcsf@users.noreply.github.com> Date: Mon, 26 Jan 2026 16:58:45 +0000 Subject: [PATCH 3/4] Always assert glob not empty --- tools/gutenberg/copy-gutenberg-build.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/gutenberg/copy-gutenberg-build.js b/tools/gutenberg/copy-gutenberg-build.js index 125dfafae8c20..e1b4183398f68 100644 --- a/tools/gutenberg/copy-gutenberg-build.js +++ b/tools/gutenberg/copy-gutenberg-build.js @@ -1072,11 +1072,10 @@ async function main() { const dest = path.join( wpIncludesDir, fileMap.destination ); fs.mkdirSync( dest, { recursive: true } ); for ( const src of fileMap.files ) { - // Don't run `src` through `glob` unless it contains asterisks, so - // that non-existing files cause errors when calling `copyFile` - const matches = src.includes( '*' ) - ? fs.globSync( path.join( gutenbergDir, src ) ) - : [ path.join( gutenbergDir, src ) ]; + const matches = fs.globSync( path.join( gutenbergDir, src ) ); + if ( ! matches.length ) { + throw new Error( `No files found matching '${ src }'` ); + } for ( const match of matches ) { fs.copyFileSync( match, From 424cee9a2d5f8dc113f96865afe79ee69d4c88dc Mon Sep 17 00:00:00 2001 From: Miguel Fonseca <150562+mcsf@users.noreply.github.com> Date: Thu, 12 Feb 2026 11:44:04 +0000 Subject: [PATCH 4/4] Prefer `glob`; `fs.globSync` requires node >= 22 --- tools/gutenberg/copy-gutenberg-build.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/gutenberg/copy-gutenberg-build.js b/tools/gutenberg/copy-gutenberg-build.js index e1b4183398f68..fdd332c35eb24 100644 --- a/tools/gutenberg/copy-gutenberg-build.js +++ b/tools/gutenberg/copy-gutenberg-build.js @@ -12,6 +12,7 @@ const fs = require( 'fs' ); const path = require( 'path' ); const json2php = require( 'json2php' ); +const glob = require( 'glob' ); // Paths const rootDir = path.resolve( __dirname, '../..' ); @@ -1072,7 +1073,7 @@ async function main() { const dest = path.join( wpIncludesDir, fileMap.destination ); fs.mkdirSync( dest, { recursive: true } ); for ( const src of fileMap.files ) { - const matches = fs.globSync( path.join( gutenbergDir, src ) ); + const matches = glob.sync( path.join( gutenbergDir, src ) ); if ( ! matches.length ) { throw new Error( `No files found matching '${ src }'` ); }