diff --git a/example/plugin.php b/example/plugin.php index cf68f40e..9d983165 100644 --- a/example/plugin.php +++ b/example/plugin.php @@ -17,8 +17,8 @@ // Useful global constants. define( 'EXAMPLE_PLUGIN_TEMPLATE_URL', plugin_dir_url( __FILE__ ) ); define( 'EXAMPLE_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); -define( 'EXAMPLE_PLUGIN_DIST_PATH', EXAMPLE_PLUGIN_PATH . 'dist/' ); -define( 'EXAMPLE_PLUGIN_DIST_URL', EXAMPLE_PLUGIN_TEMPLATE_URL . '/dist/' ); +define( 'EXAMPLE_PLUGIN_DIST_PATH', EXAMPLE_PLUGIN_PATH . 'build/' ); +define( 'EXAMPLE_PLUGIN_DIST_URL', EXAMPLE_PLUGIN_TEMPLATE_URL . '/build/' ); define( 'EXAMPLE_PLUGIN_INC', EXAMPLE_PLUGIN_PATH . 'includes/' ); define( 'EXAMPLE_PLUGIN_BLOCK_DIR', EXAMPLE_PLUGIN_INC . 'blocks/' ); define( 'EXAMPLE_PLUGIN_BLOCK_DIST_DIR', EXAMPLE_PLUGIN_PATH . 'build/blocks/' ); @@ -28,6 +28,17 @@ * Register the block */ function register_block() { + + $asset_file = include EXAMPLE_PLUGIN_DIST_PATH . 'index.asset.php'; + + wp_enqueue_script( + 'example-block-editor-script', + EXAMPLE_PLUGIN_DIST_URL . 'index.js', + $asset_file['dependencies'], + $asset_file['version'], + true + ); + if ( file_exists( EXAMPLE_PLUGIN_BLOCK_DIST_DIR ) ) { $block_json_files = glob( EXAMPLE_PLUGIN_BLOCK_DIST_DIR . '*/block.json' ); foreach ( $block_json_files as $filename ) { diff --git a/example/src/index.js b/example/src/index.js index d0048610..14f017e4 100644 --- a/example/src/index.js +++ b/example/src/index.js @@ -1,14 +1 @@ -import './blocks/hello-world'; import './extensions/background-pattern'; -import './blocks/icon-picker-example'; -import './blocks/repeater-component-example'; -import './blocks/link-example'; -import './blocks/image-example'; -import './blocks/content-search-example'; -import './blocks/rich-text-character-limit'; -import './blocks/post-title'; -import './blocks/post-featured-image'; -import './blocks/content-item'; -import './blocks/hero'; -import './blocks/post-meta'; -import './blocks/inner-blocks-slider'; diff --git a/example/webpack.config.js b/example/webpack.config.js new file mode 100644 index 00000000..d60cb39e --- /dev/null +++ b/example/webpack.config.js @@ -0,0 +1,9 @@ +const defaultConfig = require( '@wordpress/scripts/config/webpack.config' ); + +module.exports = { + ...defaultConfig, + entry: { + ...defaultConfig.entry(), + 'index': './src/index.js', + }, +};