Sample WordPress plugin for setting up a project with Yarn, Webpack, BrowserSync and React. Tailored to creating a wp-admin page, but completely flexible and can be used for themes as well.
Companion blog post: https://deliciousbrains.com/develop-wordpress-plugin-webpack-3-react/
- Clone repo to your
wp-content/plugins
folder - In
config.json
change theproxyURL
to point to your WordPress admin page or plugin page. - In your host WordPress
wp-config.php
file adddefine( 'WPRB_AJAX_BASE', 'http://sweetsite.dev/wp-json/wprb/v1' );
and update it to point to your REST API base - Modify any WordPress config in
wp-react-boilerplate.php
. Rename files/methods/strings as necessary. - Activate the plugin in wp-admin
cd
into your checked out folder and runyarn
- Run
yarn start
to get Webpack and BrowserSync running
yarn build
A production-ready WordPress plugin will be built in the wp-react-boilerplate-built
folder.