From 645579df583498cf3482ffc2d18daaf2f7c5b7b2 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Wed, 29 Jan 2020 15:19:47 +0100 Subject: [PATCH] Build: Include block.json files in the build output --- bin/build-plugin-zip.sh | 2 +- packages/block-library/src/shortcode/index.php | 12 +++++++----- webpack.config.js | 6 ++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/build-plugin-zip.sh b/bin/build-plugin-zip.sh index 15eabca56530b..d68c58f0c9edb 100755 --- a/bin/build-plugin-zip.sh +++ b/bin/build-plugin-zip.sh @@ -109,7 +109,7 @@ npm run build php bin/generate-gutenberg-php.php > gutenberg.tmp.php mv gutenberg.tmp.php gutenberg.php -build_files=$(ls build/*/*.{js,css,asset.php} build/block-library/blocks/*.{php,json}) +build_files=$(ls build/*/*.{js,css,asset.php} build/block-library/blocks/*.php build/block-library/blocks/*/block.json) # Generate the plugin zip file. status "Creating archive... 🎁" diff --git a/packages/block-library/src/shortcode/index.php b/packages/block-library/src/shortcode/index.php index ce227a16df562..cfa8ab97dfa2b 100644 --- a/packages/block-library/src/shortcode/index.php +++ b/packages/block-library/src/shortcode/index.php @@ -21,13 +21,15 @@ function render_block_core_shortcode( $attributes, $content ) { * Registers the `core/shortcode` block on server. */ function register_block_core_shortcode() { - $path = __DIR__ . '/shortcode.json'; + $path = __DIR__ . '/shortcode/block.json'; $metadata = json_decode( file_get_contents( $path ), true ); register_block_type( - 'core/shortcode', - array( - 'attributes' => $metadata['attributes'], - 'render_callback' => 'render_block_core_shortcode', + $metadata['name'], + array_merge( + $metadata, + array( + 'render_callback' => 'render_block_core_shortcode', + ) ) ); } diff --git a/webpack.config.js b/webpack.config.js index 306ea1e17a193..66a13dd8cd619 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -153,12 +153,10 @@ module.exports = { .replace( /(add_action\(\s*'init',\s*'gutenberg_register_block_[^']+'(?!,))/, '$1, 20' ); }, }, - ] ), - new CopyWebpackPlugin( [ { - from: './packages/block-library/src/+(shortcode)/block.json', + from: './packages/block-library/src/*/block.json', test: new RegExp( `([\\w-]+)${ escapeRegExp( sep ) }block\\.json$` ), - to: 'build/block-library/blocks/[1].json', + to: 'build/block-library/blocks/[1]/block.json', }, ] ), new DependencyExtractionWebpackPlugin( { injectPolyfill: true } ),