@roots/vite-plugin weekly downloads statistics
By roots · npm · Vite plugins
A Vite plugin for working with WordPress.
@roots/vite-plugin has 14,812 recorded weekly downloads on npm, an increase of 15.3% over the past 30 days, ranking #1140 of 3,247 tracked listings.
About @roots/vite-plugin
Vite Plugin for WordPress
<a href="https://www.npmjs.com/package/@roots/vite-plugin"><img alt="npm version" src="https://img.shields.io/npm/v/@roots/vite-plugin.svg?color=%23525ddc&style=flat-square"></a> <a href="https://www.npmjs.com/package/@roots/vite-plugin"><img alt="npm downloads" src="https://img.shields.io/npm/dt/@roots/vite-plugin?label=downloads&colorB=2b3072&colorA=525ddc&style=flat-square"></a> <a href="https://github.com/roots/vite-plugin/actions/workflows/tests.yml"><img alt="Build Status" src="https://img.shields.io/github/actions/workflow/status/roots/vite-plugin/tests.yml?color=%23525ddc&style=flat-square"></a> <a href="https://twitter.com/rootswp"><img alt="Follow Roots" src="https://img.shields.io/badge/follow%20@rootswp-1da1f2?logo=twitter&logoColor=ffffff&message=&style=flat-square"></a> <a href="https://github.com/sponsors/roots"><img src="https://img.shields.io/badge/sponsor%20roots-525ddc?logo=github&style=flat-square&logoColor=ffffff&message=" alt="Sponsor Roots"></a>
Here lives a Vite plugin for WordPress development.
Support us
Roots is an independent open source org, supported only by developers like you. Your sponsorship funds WP Packages and the entire Roots ecosystem, and keeps them independent. Support us by purchasing Radicle or sponsoring us on GitHub — sponsors get access to our private Discord.
Features
- 🔄 Transforms
@wordpress/*imports into globalwp.*references - 📦 Generates dependency manifest for WordPress enqueuing
- 🎨 Generates theme.json from Tailwind CSS configuration (colors, fonts, font sizes, border radius)
- 🔥 Hot Module Replacement (HMR) support for the WordPress editor
Installation
npm install @roots/vite-plugin --save-dev
Usage
Start by adding the base plugin to your Vite config:
// vite.config.js
import { defineConfig } from "vite";
import { wordpressPlugin } from "@roots/vite-plugin";
export default defineConfig({
plugins: [wordpressPlugin()],
});
Once you've added the plugin, WordPress dependencies referenced in your code will be transformed into global wp.* references.
When WordPress dependencies are transformed, a manifest containing the required dependencies will be generated called editor.deps.json.
JSX compiles to wp.element.createElement, so components render with WordPress's React. Imports of react, react-dom, and react/jsx-runtime, including those inside packages like @wordpress/dataviews, use WordPress's React when its react, react-dom, and react-jsx-runtime scripts are on the page (they're listed in editor.deps.json) and fall back to the bundled copy otherwise. To bundle your own React and JSX runtime instead, set jsx: false.
External Mappings for Third-Party Plugins
The plugin can also handle third-party WordPress plugins that expose global JavaScript APIs, such as Advanced Custom Fields (ACF) or WooCommerce. This allows you to import these dependencies in your code while ensuring they're treated as external dependencies and properly enqueued by WordPress.
// vite.config.js
import { defineConfig } from "vite";
import { wordpressPlugin } from "@roots/vite-plugin";
export default defineConfig({
plugins: [
wordpressPlugin({
externalMappings: {
"acf-input": {
global: ["acf", "input"],
handle: "acf-input",
},
"woocommerce-blocks": {
global: ["wc", "blocks"],
handle: "wc-blocks",
},
},
}),
],
});
With this configuration, you can import from these packages in your code:
import { Field, FieldGroup } from "acf-input";
import { registerBlockType } from "woocommerce-blocks";
The plugin will transform these imports into global references:
const Field = acf.input.Field;
const FieldGroup = acf.input.FieldGroup;
const registerBlockType = wc.blocks.registerBlockType;
The handle value is added to the dependency manifest (editor.deps.json) so WordPress knows to enqueue these scripts before your code runs.
Editor HMR Support
The plugin automatically enables CSS Hot Module Replacement (HMR) for the WordPress editor.
[!NOTE] JavaScript HMR is not supported at this time. JS changes will trigger a full page reload.
You can customize the HMR behavior in your Vite config:
// vite.config.js
import { defineConfig } from "vite";
import { wordpressPlugin } from "@roots/vite-plugin";
export default defineConfig({
plugins: [
wordpressPlugin({
hmr: {
// Enable/disable HMR (default: true)
enabled: true,
// Pattern to match editor entry points (default: /editor/)
editorPattern: /editor/,
// Name of the editor iframe element (default: 'editor-canvas')
iframeName: "editor-canvas",
},
}),
],
});
Theme.json Generation
When using this plugin for theme development, you have the option of generating a theme.json file from your Tailwind CSS configuration.
To enable this feature, add the wordpressThemeJson plugin to your Vite config:
// vite.config.js
import { defineConfig } from "vite";
import { wordpressThemeJson } from "@roots/vite-plugin";
export default defineConfig({
plugins: [
wordpressThemeJson({
// Optional: Configure shade labels
shadeLabels: {
100: "Lightest",
900: "Darkest",
},
// Optional: Configure font family labels
fontLabels: {
sans: "Sans Serif",
mono: "Monospace",
inter: "Inter Font",
},
// Optional: Configure font size labels
fontSizeLabels: {
sm: "Small",
base: "Default",
lg: "Large",
},
// Optional: Configure border radius labels
borderRadiusLabels: {
sm: "Small",
md: "Medium",
lg: "Large",
full: "Full",
},…
Description from the npm listing.
- vite
- vite-plugin
- wordpress
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 Vite plugins plugins
All 20 @roots/vite-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/@roots/vite-plugin. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.