Skip to content

Commit

Permalink
Improve webpack config
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed May 8, 2023
1 parent 2740821 commit cf365be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/experimental/interactivity-api/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ function gutenberg_block_core_file_add_directives_to_content( $block_content, $b
$processor = new WP_HTML_Tag_Processor( $block_content );
$processor->next_tag();
$processor->set_attribute( 'data-wp-island', '' );
$processor->next_tag( 'object' );
$processor->set_attribute( 'data-wp-init', 'effects.core.file.init' );
$processor->set_attribute( 'hidden', true );
return $processor->get_updated_html();
}
add_filter( 'render_block_core/file', 'gutenberg_block_core_file_add_directives_to_content', 10, 3 );
Expand Down
8 changes: 5 additions & 3 deletions packages/block-library/src/file/view/interactivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
* Internal dependencies
*/
import { store } from '../../utils/interactivity';
import { hidePdfEmbedsOnUnsupportedBrowsers } from '../utils';
import { browserSupportsPdfs } from '../utils';

store( {
effects: {
core: {
file: {
init() {
hidePdfEmbedsOnUnsupportedBrowsers();
init( { ref } ) {
if ( browserSupportsPdfs() ) {
ref.removeAttribute( 'hidden' );
}
},
},
},
Expand Down
6 changes: 6 additions & 0 deletions tools/webpack/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ module.exports = [
].filter( Boolean ),
},
{
...baseConfig,
watchOptions: {
aggregateTimeout: 200,
},
name: 'interactivity',
entry: {
file: './packages/block-library/src/file/view/interactivity.js',
},
Expand All @@ -229,6 +234,7 @@ module.exports = [
path: join( __dirname, '..', '..', 'build', 'block-library' ),
},
optimization: {
...baseConfig.optimization,
runtimeChunk: {
name: 'vendors',
},
Expand Down

0 comments on commit cf365be

Please sign in to comment.