Skip to content
Draft
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
37 changes: 33 additions & 4 deletions tools/gutenberg/copy-gutenberg-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '../..' );
Expand Down Expand Up @@ -98,6 +99,18 @@ 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',
},
{
files: [ 'packages/icons/src/library/*.svg' ],
destination: 'icons/library',
},
],
};

/**
Expand Down Expand Up @@ -982,10 +995,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 } );
Expand Down Expand Up @@ -1057,6 +1067,25 @@ 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 ) {
const matches = glob.sync( path.join( gutenbergDir, src ) );
if ( ! matches.length ) {
throw new Error( `No files found matching '${ src }'` );
}
for ( const match of matches ) {
fs.copyFileSync(
match,
path.join( dest, path.basename( match ) )
);
}
}
}

// 7. Generate script-modules-packages.min.php from individual asset files
console.log( '\n📦 Generating script-modules-packages.min.php...' );
generateScriptModulesPackages();
Expand Down
Loading