A simple starter kit to develop wp plugin with webpack and react.
This repository has the goal to make simple develop WP Plugin with React.
You have to develop react in isolate way, then test it in WP running live version of React app and then build react and zip for create and distribute your plugin.
WP Plugin can activate React in frontend by shortcode or insert in the_content of posts.
Also the WP Plugin configuration active React to show data, for example you can import News throw wep api call by React.
-
- Go to react folder
- Edit file index.js for create frontend app (shortcode or post page)
- Edit file admin.js for create admin app
- use command npm start to develop react app outside WP
- use command npm run build to build react app to show outside WP
- use command *npm run startBuilded to exec builded react app outside WP (use http-server package)
- use command npm run wpBuild to build react app in WP folder
-
(after create react app)
- Go to mgr_wppwr_plugin_local
- edit constant $localServer with the url of react started version (for example:
http://localhost:8080
) - zip folder mgr_wppwr_plugin_local and import (and active) it in your Wordpress (or copy folder in wp-content/plugin/ Wordpress folder)
- start react with npm start command
- edit file and see the result inside WP. You can see and correct the design before build the react app
-
(after create react app)
- Go to mgr_wppwr_plugin
- edit plugin files
- zip folder mgr_wppwr_plugin and import (and active) it in your Wordpress (or copy folder in wp-content/plugin/ Wordpress folder)
- For webpack 5 configuration
taniarascia/webpack-boilerplate