{"id":42220,"library":"vite-patcher","title":"vite-patcher","description":"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.","status":"active","version":"0.0.8","language":"javascript","source_language":"en","source_url":"https://github.com/node-ecosystem/vite-patcher","tags":["javascript","vite","patch","patches","pwa"],"install":[{"cmd":"npm install vite-patcher","lang":"bash","label":"npm"},{"cmd":"yarn add vite-patcher","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-patcher","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency – used to read and modify vite config files","package":"vite","optional":false},{"reason":"peer dependency – optional, but when present it enables automatic edge case handling for SSR","package":"vike","optional":true}],"imports":[{"note":"vite-patcher is a CLI tool, not a library. There is no programmatic API; only use via command line.","wrong":"import { vitePatcher } from 'vite-patcher'","symbol":"vite-patcher","correct":"npx vite-patcher pwa"},{"note":"vite-plugin-pwa is ESM only; use import syntax.","wrong":"const VitePWA = require('vite-plugin-pwa')","symbol":"vite-plugin-pwa","correct":"import { VitePWA } from 'vite-plugin-pwa'"},{"note":"vike is ESM only; use import with default export.","wrong":"const vike = require('vike')","symbol":"vike","correct":"import vike from 'vike'"}],"quickstart":{"code":"// Install dependencies\nnpm install -D vite-patcher vite-plugin-pwa vite\n// For vike projects also install vike\nnpm install vike\n\n// Run the patron to inject vite-plugin-pwa into vite.config\nnpx vite-patcher pwa\n\n// Example vite.config.ts generated output:\nimport { defineConfig } from 'vite';\nimport vike from 'vike';\nimport { VitePWA } from 'vite-plugin-pwa';\n\nexport default defineConfig({\n  plugins: [\n    vike(),\n    VitePWA({ registerType: 'autoUpdate' }),\n  ],\n});","lang":"typescript","description":"Installs vite-patcher and vite-plugin-pwa, then uses the CLI to automate adding PWA support to a Vite+vike project."},"warnings":[{"fix":"Use npx, yarn dlx, or pnpm dlx to run the command.","message":"vite-patcher is a CLI tool, not a JS library. Do not import it in code.","severity":"gotcha","affected_versions":">=0.0"},{"fix":"Manually check https://vite-plugin-pwa.netlify.app/ for the latest API.","message":"The pwa patch may inject an outdated configuration for vite-plugin-pwa. Always verify the generated code.","severity":"deprecated","affected_versions":">=0.0.8"},{"fix":"Only use vite-patcher in Vite projects.","message":"If 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.","severity":"gotcha","affected_versions":">=0.0"},{"fix":"Backup your vite config before running the tool.","message":"vite-patcher may not preserve all custom formatting in vite.config.yo; it respects indentation but could miscode comments or unusual structures.","severity":"gotcha","affected_versions":">=0.0.8"}],"env_vars":null,"search_vec":"'activ':63 'add':30 'autom':13 'avoid':59 'built':53 'built-in':52 'cli':10 'code':20 'config':29 'configur':19 'current':40 'detect':55 'develop':62 'doubl':60 'ecosystem':69 'exist':28 'file':24 'format':38 'github':65 'import':32 'initi':35 'inject':14,61 'javascript':70 'necessari':31 'node':68 'node-ecosystem':67 'patch':44,72,73 'patcher':3,6 'plugin':17,34,48 'preserv':37 'pwa':43,49,74 'read':26 'support':41 'tool':11 'v0.0.8':7 'vike':57 'vite':2,5,16,47,71 'vite-patch':1,4 'vite-plugin-pwa':46 'vite.config':23","created_at":"2026-06-04T18:56:12.653484+00:00","updated_at":"2026-06-04T18:56:12.653484+00:00","problems":[{"fix":"Run 'npm install -D vite-patcher' in your project root, or use npx.","cause":"vite-patcher is not installed globally or as a dev dependency","error":"vite-patcher: command not found"},{"fix":"Run 'npm install vite' in your project.","cause":"vite is not installed (peer dependency missing)","error":"Error: Cannot find module 'vite'"},{"fix":"Run 'npm install vite-plugin-pwa' before using the pwa patch.","cause":"Required plugin not installed","error":"Error: vite-plugin-pwa is not installed but pwa patch is used"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/node-ecosystem/vite-patcher#readme","github":"https://github.com/node-ecosystem/vite-patcher","docs":null,"changelog":null,"pypi":null,"npm":"vite-patcher","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}