Build: Split packages and blocks to their webpack configs.

This also adds support for the viewScript for blocks fixing 
the PDF preview for file blocks.

Props desrosj, gziolo.
See #53397.


git-svn-id: https://develop.svn.wordpress.org/trunk@51259 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Riad Benguella
2021-06-29 15:08:16 +00:00
parent da88164ba5
commit 51cbe7eeb7
9 changed files with 267 additions and 124 deletions

View File

@@ -48,6 +48,7 @@
},
"editorScript": "tests-notice-editor-script",
"script": "tests-notice-script",
"viewScript": "tests-notice-view-script",
"editorStyle": "tests-notice-editor-style",
"style": "tests-notice-style"
}

View File

@@ -132,6 +132,10 @@ class WP_Test_Block_Register extends WP_UnitTestCase {
'unit-tests-my-block-script',
generate_block_asset_handle( $block_name, 'script' )
);
$this->assertSame(
'unit-tests-my-block-view-script',
generate_block_asset_handle( $block_name, 'viewScript' )
);
$this->assertSame(
'unit-tests-my-block-editor-style',
generate_block_asset_handle( $block_name, 'editorStyle' )
@@ -156,6 +160,10 @@ class WP_Test_Block_Register extends WP_UnitTestCase {
'wp-block-paragraph',
generate_block_asset_handle( $block_name, 'script' )
);
$this->assertSame(
'wp-block-paragraph-view',
generate_block_asset_handle( $block_name, 'viewScript' )
);
$this->assertSame(
'wp-block-paragraph-editor',
generate_block_asset_handle( $block_name, 'editorStyle' )
@@ -372,6 +380,7 @@ class WP_Test_Block_Register extends WP_UnitTestCase {
);
$this->assertSame( 'tests-notice-editor-script', $result->editor_script );
$this->assertSame( 'tests-notice-script', $result->script );
$this->assertSame( 'tests-notice-view-script', $result->view_script );
$this->assertSame( 'tests-notice-editor-style', $result->editor_style );
$this->assertSame( 'tests-notice-style', $result->style );