-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use webpack-config with wp-scripts (#6)
- Loading branch information
Showing
8 changed files
with
207 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## webpack config example plugin | ||
|
||
WordPress plugin to showcase how to work with webpack-config package. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* Plugin Name: Understanding Gutenberg: webpack-config | ||
* Plugin URI: https://github.com/nosolosw/understanding-gutenberg | ||
* Description: Plugin to showcase how to work with webpack-config. | ||
* Version: 0.0.1 | ||
*/ | ||
|
||
function webpack_config_plugin_script_register() { | ||
wp_register_script( | ||
'webpack-config-plugin-block', | ||
plugins_url( 'build/index.js', __FILE__ ), | ||
array( 'wp-blocks', 'wp-element' ) | ||
); | ||
} | ||
add_action( 'init', 'webpack_config_plugin_script_register' ); | ||
|
||
function webpack_config_plugin_script_enqueue() { | ||
wp_enqueue_script( 'webpack-config-plugin-block' ); | ||
} | ||
add_action( 'enqueue_block_editor_assets', 'webpack_config_plugin_script_enqueue' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "webpack-config", | ||
"version": "1.0.0", | ||
"description": "Plugin to showcase how to work with webpack-config.", | ||
"author": "WordPress contributors", | ||
"license": "GPL-2.0-or-later", | ||
"keywords": [ | ||
"wordpress", | ||
"webpack-config" | ||
], | ||
"homepage": "https://github.com/nosolosw/understanding-gutenberg#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/nosolosw/understanding-gutenberg.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/nosolosw/understanding-gutenberg/issues" | ||
}, | ||
"main": "index.js", | ||
"devDependencies": { | ||
"@wordpress/scripts": "file:../../gutenberg/packages/scripts" | ||
}, | ||
"scripts": { | ||
"analyze": "GUTENBERG_BUNDLE_ANALYZER=true wp-scripts build", | ||
"start": "wp-scripts start", | ||
"build": "wp-scripts build" | ||
}, | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { createElement } from '@wordpress/element'; | ||
import { registerBlockType } from '@wordpress/blocks'; | ||
|
||
registerBlockType( 'blockexample-plugin/block', { | ||
title: 'Love', | ||
icon: 'heart', | ||
category: 'common', | ||
edit: function() { | ||
return ( createElement( | ||
'p', | ||
{}, | ||
'I ♥ Gutenberg.' | ||
) ); | ||
}, | ||
save: function() { | ||
return ( createElement( | ||
'p', | ||
{}, | ||
'I ♥ .' | ||
) ); | ||
}, | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const config = require( '@wordpress/scripts/config/webpack.config.js' ); | ||
|
||
module.exports = Object.assign( {}, config ); |