WordPress Vite Plugin (v1.6.0) is a Vite plugin that integrates Vite into WordPress theme/plugin development, providing hot module replacement, asset bundling, and automatic enqueuing. It supports Vite 3-8, requires Node >=16, ships TypeScript types, and offers a streamlined setup with minimal configuration compared to manual webpack or custom build setups. Release cadence is irregular; key differentiators include native HMR in WordPress admin, automatic asset manifest parsing, and compatibility with both Classic and Block themes. v1.6 introduces support for Vite 6 and 7/8 prereleases.
npm install wordpress-vite-pluginVerified import paths — ran on the pinned version, not inferred.
Minimal Vite config for WordPress plugin: sets up HMR and build with two input files and custom output structure.
Upgrade Vite to ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0
Use wordpressVitePlugin({...}) instead of wordpressVitePlugin as a direct plugin.Rename 'config' to 'pluginOptions'.
Add define('WP_HOME', 'http://localhost:5173'); to wp-config.php during development.Set build.manifest: true in vite.config.js.
Run npm install wordpress-vite-plugin --save-dev and ensure package.json has 'type': 'module' or use .mjs extension.
Use import wordpressVitePlugin from 'wordpress-vite-plugin' in ESM, or const plugin = require('wordpress-vite-plugin').default in CommonJS.Ensure you call wordpressVitePlugin() as a function with options object in the plugins array.
Add build: { manifest: true } to vite.config.js.