Skip to content

Commit

Permalink
Build: Include block.json files in the build output
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Jan 29, 2020
1 parent 5cb2727 commit 645579d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bin/build-plugin-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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... 🎁"
Expand Down
12 changes: 7 additions & 5 deletions packages/block-library/src/shortcode/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
)
);
}
Expand Down
6 changes: 2 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } ),
Expand Down

0 comments on commit 645579d

Please sign in to comment.