Demonstration of how to use wordpress-shortcode-webpack-plugin with Create React App, using react-app-rewired to extend the CRA webpack config.
How I got here:
npx create-react-app my-plugin
cd my-plugin
yarn add -D react-app-rewired wordpress-shortcode-webpack-plugin
- Created
config-overrides.js
adding the webpack plugin. - Updated
package.json
to usereact-app-rewired
instead ofreact-scripts
. - (Bonus) Updated base URL to be correctly pathed for Wordpress by setting
"homepage": "/wp-content/plugins/my-plugin/assets/"
inpackage.json
. - Run
yarn build
. Done!