Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: Include block.json files in the build output #19786

Merged
merged 1 commit into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
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
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