wordpress-shortcode-webpack-plugin weekly downloads statistics
By studio-lagier · npm · Webpack plugins
Create Wordpress plugins from React apps built using Webpack
wordpress-shortcode-webpack-plugin has 5 recorded weekly downloads on npm, a decrease of 64.3% over the past 30 days, ranking #3224 of 3,247 tracked listings.
About wordpress-shortcode-webpack-plugin
wordpress-shortcode-webpack-plugin
This Webpack plugin is for Wordpress developers who want an easy way to drop React apps into Wordpress pages. It creates a simple Wordpress plugin from your Webpack configuration, registering each Webpack entry as a Wordpress shortcode.
Requires Webpack 4 or 5
Installation
npm install wordpress-shortcode-webpack-plugin
Usage
Import the plugin, tell it a bit about your desired Wordpress plugin output, and add it to your Webpack configuration.
webpack.config.js
import { WordpressShortcodeWebpackPlugin } from 'wordpress-shortcode-webpack-plugin';
export default {
entry: './src/index.js',
output: {
filename: '[name].js',
},
plugins: [
new WordpressShortcodeWebpackPlugin({
// The name of the plugin in Wordpress. Should be kebab-cased
wordpressPluginName: 'my-awesome-plugin',
// Any additional fields to put in the plugin header.
headerFields: {
author: 'Tom Lagier',
description: 'An awesome plugin that does many cool things'
// Note: Defining a version isn't necessary for Wordpress cache-busting
// if you're using [contenthash] tokens in your output. It can still be
// nice to set a version for communicating changes to users.
version: '1.2.3'
}
}),
],
}
When built, this will output the following assets in the build directory:
my-awesome-plugin/
// The main Wordpress plugin file
my-awesome-plugin.php
assets/
main.js
... other assets produced by Webpack
// Archive of the plugin that you can install to Wordpress
my-awesome-plugin.zip
Once uploaded, you can use the entrypoints specified in your Webpack configuration as shortcodes.
By default the shortcodes are registered as {pluginName}-{entryName}. For our example, the one
shortcode registered would be my-awesome-plugin-main.
So, in Wordpress, we could use the shortcode like [my-awesome-plugin-main].
You can see an example Create React App repo here.
Options
wordpressPluginName (required)
Type: string
Your plugin's name in kebab-case.
shortcodePrefix
Type: string<br/>
Default: wordpressPluginName
The prefix used instead of wordpressPluginName to create your shortcodes.
With shortcodePrefix: 'my-shortcode', the main entry shortcode would
be [my-shortcode-main].
headerFields
Type:
{
pluginUri?: string;
description?: string;
version?: string;
requiredWordpressVersion?: string;
requiredPHPVersion?: string;
author?: string;
authorUri?: string;
license?: string;
licenseUri?: string;
textDomain?: string;
domainPath?: string;
isNetworkWide?: boolean;
}
Default: {}
Header fields for the Wordpress plugin. See https://developer.wordpress.org/plugins/plugin-basics/header-requirements/#header-fields
entryToRootId
Type: object <br/>
Default: {}
A map of overrides for the root element ID for each entrypoint. By default we just use root as
the ID for the root element, per React convention. If that ID conflicts with something else on the page,
you can adjust it with this map.
{
main: 'new-main-root-id'
}
pluginTemplate
Type: string <br/>
Default: ./src/default-template.php (in the wordpress-shortcode-webpack-plugin repo)
Path to the template file that should be used to generate the Wordpress plugin file.
The template file is a PHP file with the following tokens that get replaced with content. You can customize the behavior of the Wordpress plugin by modifying the template.
{{plugin_header}}
Replaced with the Wordpress comment indicating the plugin name and other plugin metadata.
/**
* Plugin Name: My Plugin
*/
{{asset_manifest}}
Replaced with an associative array of entrypoint to an array of files that should be loaded
for that entrypoint. Required for {{shortcode_registration}} and {{shortcode_definitions}}.
$manifest = [
'main' => [
'main.js',
],
];
{{shortcode_definitions}}
Function that is invoked when the shortcode is called. Enqueues the assets for the entry and returns the React root HTML as a string.
Override this if you'd like to enhance the logic that gets run when your shortcode is run, e.g. by supplying attributes or setting global variables in the markup.
The naming convention for shortcodes that get registered is create_{entry}_app.
Requires {{shortcode_registration}}.
function create_main_app() {
enqueue_assets('main');
return '<div id="root"></div>';
}
{{shortcode_registration}}
Function that registers the shortcode definition functions and their assets with Wordpress.
function register_my_plugin_entries() {
add_shortcode('my-plugin-main', 'create_main_app');
register_assets('main');
}
{{add_action}}
Adds the {{shortcode_registration}} function as an action during Wordpress's init phase.
add_action('init', 'register_my_plugin_entries');
Build locally
Clone the project
git clone https://github.com/studio-lagier/wordpress-shortcode-webpack-plugin
Go to the project directory
cd wordpress-shortcode-webpack-plugin
Install dependencies
yarn
Build
yarn build
Running Tests
To run tests, run the following command
yarn test
License
Description from the npm listing.
- webpack
- react
- wordpress
- webpack-plugin
- wordpress-plugin
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (170)Similar npm Webpack plugins plugins
All 20 wordpress-shortcode-webpack-plugin alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/wordpress-shortcode-webpack-plugin. First seen Oct 16, 2026; last successful collection Nov 3, 2026. See the methodology.