Registry / http-networking / vite-plugin-monkey

vite-plugin-monkey

JSON →
library7.1.9jsnpmunverified

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.

npm install vite-plugin-monkey
INSTALL
IMPORT
SIG · VITE-PLUGIN-MONKEY
V
vite-plugin-monkey
http-networkingjavascriptv7.1.9
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

vitePluginMonkey
import vitePluginMonkey from 'vite-plugin-monkey'
import { vitePluginMonkey } from 'vite-plugin-monkey'
Default export, not named. Use default import syntax.
defineConfig
import { defineConfig } from 'vite'
import { defineConfig } from 'vite-plugin-monkey'
defineConfig is from Vite itself, not from this plugin.
expose
import { expose } from 'vite-plugin-monkey'
import { expose } from 'vite-plugin-monkey/dist/client'
expose is a named export from the main entry, but recommended to use the global expose provided by the plugin's inject script.

Basic Vite config for a userscript that shows on example.com and uses GM_notification.

import { defineConfig } from 'vite'; import vitePluginMonkey from 'vite-plugin-monkey'; export default defineConfig({ plugins: [ vitePluginMonkey({ entry: 'src/main.ts', userscript: { name: 'Hello World', namespace: 'https://example.com', version: '1.0.0', description: 'My first userscript', author: 'You', match: ['https://example.com/*'], grant: ['GM_notification'], }, build: { fileName: 'hello.user.js', }, }), ], });
Debug
Known issues
breakingvite-plugin-monkey v7 dropped support for Vite 5 and below. Requires Vite ^6.0.0 || ^7.0.0.
fix
Upgrade Vite to 6.x or 7.x, or stay on vite-plugin-monkey v6 if using Vite 5.
affects: >=7.0.0 <8.0.0
gotchaIn 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.
fix
Use 'styleImport' feature (v7.1.0+) for better CSS injection support, or trigger a full reload after style changes.
affects: >=6.0.0 <8.0.0
gotchaWhen using 'run-at document-start', document.head may be null, leading to errors in style injection or script execution.
fix
Upgrade to v7.1.5 or later which fixes this issue.
affects: >=7.0.0 <7.1.5
deprecatedThe 'expose' function in client-side code is being replaced by a global injection pattern. Direct use of 'expose' may be removed in future versions.
fix
Use the global 'expose' provided by the plugin's inject script rather than importing it directly.
affects: >=7.0.0 <8.0.0
Errors
Common errors & fixes
Error: Cannot find module 'vite-plugin-monkey'
Missing dependency or incorrect import path.
fix
Run 'npm install vite-plugin-monkey --save-dev' (or yarn/pnpm equivalent).
TypeError: vitePluginMonkey is not a function
Incorrect import: using named import instead of default import.
fix
Change to 'import vitePluginMonkey from 'vite-plugin-monkey''.
[vite] Internal server error: Cannot read properties of null (reading 'head')
document.head is null when run-at document-start and using an older version of the plugin.
fix
Upgrade vite-plugin-monkey to v7.1.5 or later, or modify the userscript to run at document-end.
Upgrade
Version history
7.1.9latest on npm
Audit
Dependencies
viterequiredPeer dependency: Vite plugin system requires Vite as the build tool and dev server.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
vite-plugin-monkey — npm install vite-plugin-monkey · libregistry