{"id":22747,"library":"vite-plugin-monkey","title":"vite-plugin-monkey","description":"A Vite plugin for developing and building userscripts (.user.js) targeting Tampermonkey, Violentmonkey, Greasemonkey, and ScriptCat. Current stable version is 7.1.9, with frequent releases addressing edge cases and HMR improvements. Key differentiator: leverages Vite's fast dev server with hot reload for userscripts, supports TypeScript, CSS modules, and advanced GM_ API types. Requires Vite ^6.0.0 || ^7.0.0 as peer dependency.","status":"active","version":"7.1.9","language":"javascript","source_language":"en","source_url":"https://github.com/lisonge/vite-plugin-monkey","tags":["javascript","vite","vite-plugin","monkey","Tampermonkey","Violentmonkey","Greasemonkey","userscript","greasyfork","typescript"],"install":[{"cmd":"npm install vite-plugin-monkey","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-monkey","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-monkey","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: Vite plugin system requires Vite as the build tool and dev server.","package":"vite","optional":false}],"imports":[{"note":"Default export, not named. Use default import syntax.","wrong":"import { vitePluginMonkey } from 'vite-plugin-monkey'","symbol":"vitePluginMonkey","correct":"import vitePluginMonkey from 'vite-plugin-monkey'"},{"note":"defineConfig is from Vite itself, not from this plugin.","wrong":"import { defineConfig } from 'vite-plugin-monkey'","symbol":"defineConfig","correct":"import { defineConfig } from 'vite'"},{"note":"expose is a named export from the main entry, but recommended to use the global expose provided by the plugin's inject script.","wrong":"import { expose } from 'vite-plugin-monkey/dist/client'","symbol":"expose","correct":"import { expose } from 'vite-plugin-monkey'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport vitePluginMonkey from 'vite-plugin-monkey';\n\nexport default defineConfig({\n  plugins: [\n    vitePluginMonkey({\n      entry: 'src/main.ts',\n      userscript: {\n        name: 'Hello World',\n        namespace: 'https://example.com',\n        version: '1.0.0',\n        description: 'My first userscript',\n        author: 'You',\n        match: ['https://example.com/*'],\n        grant: ['GM_notification'],\n      },\n      build: {\n        fileName: 'hello.user.js',\n      },\n    }),\n  ],\n});","lang":"typescript","description":"Basic Vite config for a userscript that shows on example.com and uses GM_notification."},"warnings":[{"fix":"Upgrade Vite to 6.x or 7.x, or stay on vite-plugin-monkey v6 if using Vite 5.","message":"vite-plugin-monkey v7 dropped support for Vite 5 and below. Requires Vite ^6.0.0 || ^7.0.0.","severity":"breaking","affected_versions":">=7.0.0 <8.0.0"},{"fix":"Use 'styleImport' feature (v7.1.0+) for better CSS injection support, or trigger a full reload after style changes.","message":"In HMR, styles might not update correctly if they are imported via CSS modules or injected dynamically. A full page reload or manual style reload may be needed.","severity":"gotcha","affected_versions":">=6.0.0 <8.0.0"},{"fix":"Upgrade to v7.1.5 or later which fixes this issue.","message":"When using 'run-at document-start', document.head may be null, leading to errors in style injection or script execution.","severity":"gotcha","affected_versions":">=7.0.0 <7.1.5"},{"fix":"Use the global 'expose' provided by the plugin's inject script rather than importing it directly.","message":"The 'expose' function in client-side code is being replaced by a global injection pattern. Direct use of 'expose' may be removed in future versions.","severity":"deprecated","affected_versions":">=7.0.0 <8.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'npm install vite-plugin-monkey --save-dev' (or yarn/pnpm equivalent).","cause":"Missing dependency or incorrect import path.","error":"Error: Cannot find module 'vite-plugin-monkey'"},{"fix":"Change to 'import vitePluginMonkey from 'vite-plugin-monkey''.","cause":"Incorrect import: using named import instead of default import.","error":"TypeError: vitePluginMonkey is not a function"},{"fix":"Upgrade vite-plugin-monkey to v7.1.5 or later, or modify the userscript to run at document-end.","cause":"document.head is null when run-at document-start and using an older version of the plugin.","error":"[vite] Internal server error: Cannot read properties of null (reading 'head')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}