A Vite plugin enabling hot module replacement (HMR) for web components, primarily designed for LitElement and similar libraries. Current stable version is 0.1.3, with low release cadence. It is a fork of @open-wc/dev-server-hmr adapted for Vite's plugin system. Key differentiator: seamless HMR for custom elements in Vite projects without additional configuration. Supports TypeScript, configurable inclusion patterns, and presets for popular libraries (Lit, FAST, etc.). Primarily used with Vite 2+.
npm install vite-plugin-web-components-hmrVerified import paths — ran on the pinned version, not inferred.
Basic setup with Lit preset. Add plugin to Vite config to enable HMR for components matching the include pattern.
Upgrade Vite to version 2 or higher.
Use import syntax in an ES module context.
Refer to @open-wc/dev-server-hmr documentation for available options.
Ensure include globs cover all component files, e.g., 'src/components/**/*.ts'.
Check preset definitions; can create custom presets using the same format.
Run `npm install -D vite-plugin-web-components-hmr` or equivalent.
Use `import { hmrPlugin } from 'vite-plugin-web-components-hmr'`.Ensure the package is installed. Add to `optimizeDeps.include` if necessary.
Wrap presets in an array: `presets: [presets.lit]`.