vite-plugin-dev-manifest
raw JSON → 1.5.0 verified Mon Apr 27 auth: no javascript
Vite plugin that generates a manifest.json file during development, enabling backend integrations (e.g., WordPress) to consume the same generated manifest used in production builds. v1.5.0 supports Vite 2.7 through 8.x. Unlike the standard manifest plugin, this runs in dev mode without building, injecting current scripts and styles. Ships TypeScript types.
Common errors
error Cannot find module 'vite-plugin-dev-manifest' or its corresponding type declarations. ↓
cause Missing installed package or TypeScript module resolution not set to 'node' or 'node16'.
fix
npm install vite-plugin-dev-manifest --save-dev; ensure tsconfig.json has 'moduleResolution': 'node' or 'nodenext'
error Error: [vite-plugin-dev-manifest] The "path" argument must be of type string. Received undefined ↓
cause Options object missing 'filename' key or passed undefined/null.
fix
Provide a filename string; e.g., devManifest({ filename: 'dev-manifest.json' })
error TypeError: devManifest is not a function ↓
cause Using default import instead of named import.
fix
Change to: import { devManifest } from 'vite-plugin-dev-manifest'
Warnings
gotcha Plugin does not write manifest file for SSR builds; only client bundles generate manifest. ↓
fix Use the production manifest plugin for SSR entries.
breaking Options changed in v1.0.0; 'fileName' renamed to 'filename'. ↓
fix Use 'filename' instead of 'fileName'.
deprecated Option 'outputDir' is deprecated and ignored; manifest is always placed in Vite's output directory. ↓
fix Remove 'outputDir' from options.
gotcha Requires Vite>=2.7.0; older versions not supported. ↓
fix Upgrade Vite to 2.7+ or use legacy alternative.
Install
npm install vite-plugin-dev-manifest yarn add vite-plugin-dev-manifest pnpm add vite-plugin-dev-manifest Imports
- devManifest wrong
import devManifest from 'vite-plugin-dev-manifest'correctimport { devManifest } from 'vite-plugin-dev-manifest' - DevManifestOptions
import type { DevManifestOptions } from 'vite-plugin-dev-manifest' - Plugin wrong
const devManifest = require('vite-plugin-dev-manifest')correctimport { devManifest } from 'vite-plugin-dev-manifest'; const manifestPlugin = devManifest(); - vite config wrong
// wrong: passing options as positional argument instead of object import { devManifest } from 'vite-plugin-dev-manifest' export default defineConfig({ plugins: [devManifest({})] // correct usage is same but this is fine; wrong: missing parentheses })correct// vite.config.ts import { defineConfig } from 'vite' import { devManifest } from 'vite-plugin-dev-manifest' export default defineConfig({ plugins: [devManifest()] })
Quickstart
// vite.config.ts
import { defineConfig } from 'vite'
import { devManifest } from 'vite-plugin-dev-manifest'
export default defineConfig({
plugins: [devManifest({
filename: 'manifest.json',
base: '/wp-content/themes/mytheme/build/',
transform(manifest) {
return {
...manifest,
customKey: 'value'
}
}
})]
})