Registry / devops / vite-patcher

vite-patcher

JSON →
library0.0.8jsnpmunverified

vite-patcher (v0.0.8) is a CLI tool that automates injection of Vite plugins and configuration code into your vite.config.* file. It reads the existing config, adds necessary imports and plugin initializations, and preserves formatting. It currently supports the 'pwa' patch for vite-plugin-pwa and has built-in detection for vike to avoid double injection. Developed actively on GitHub under node-ecosystem.

npm install vite-patcher
INSTALL
IMPORT
SIG · VITE-PATCHER
V
vite-patcher
devopsjavascriptv0.0.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

vite-patcher
npx vite-patcher pwa
import { vitePatcher } from 'vite-patcher'
vite-patcher is a CLI tool, not a library. There is no programmatic API; only use via command line.
vite-plugin-pwa
import { VitePWA } from 'vite-plugin-pwa'
const VitePWA = require('vite-plugin-pwa')
vite-plugin-pwa is ESM only; use import syntax.
vike
import vike from 'vike'
const vike = require('vike')
vike is ESM only; use import with default export.

Installs vite-patcher and vite-plugin-pwa, then uses the CLI to automate adding PWA support to a Vite+vike project.

// Install dependencies npm install -D vite-patcher vite-plugin-pwa vite // For vike projects also install vike npm install vike // Run the patron to inject vite-plugin-pwa into vite.config npx vite-patcher pwa // Example vite.config.ts generated output: import { defineConfig } from 'vite'; import vike from 'vike'; import { VitePWA } from 'vite-plugin-pwa'; export default defineConfig({ plugins: [ vike(), VitePWA({ registerType: 'autoUpdate' }), ], });
Debug
Known issues
gotchavite-patcher is a CLI tool, not a JS library. Do not import it in code.
fix
Use npx, yarn dlx, or pnpm dlx to run the command.
affects: >=0.0
deprecatedThe pwa patch may inject an outdated configuration for vite-plugin-pwa. Always verify the generated code.
fix
Manually check https://vite-plugin-pwa.netlify.app/ for the latest API.
affects: >=0.0.8
gotchaIf your project uses a module bundler like webpack or esbuild, vite-patcher will try to read vite.config even if not applicable. Ensure Vite is actually used.
fix
Only use vite-patcher in Vite projects.
affects: >=0.0
gotchavite-patcher may not preserve all custom formatting in vite.config.yo; it respects indentation but could miscode comments or unusual structures.
fix
Backup your vite config before running the tool.
affects: >=0.0.8
Errors
Common errors & fixes
vite-patcher: command not found
vite-patcher is not installed globally or as a dev dependency
fix
Run 'npm install -D vite-patcher' in your project root, or use npx.
Error: Cannot find module 'vite'
vite is not installed (peer dependency missing)
fix
Run 'npm install vite' in your project.
Error: vite-plugin-pwa is not installed but pwa patch is used
Required plugin not installed
fix
Run 'npm install vite-plugin-pwa' before using the pwa patch.
Upgrade
Version history
0.0.8latest on npm
Audit
Dependencies
viterequiredpeer dependency – used to read and modify vite config files
vikeoptionalpeer dependency – optional, but when present it enables automatic edge case handling for SSR
Agent activity
4 hits · last 30 days
node
4
Resources
vite-patcher — npm install vite-patcher · libregistry