$ account lisonge
vite-plugin-monkey is a Vite plugin that compiles userscripts (user.js) for Tampermonkey, Violentmonkey, Greasemonkey, and ScriptCat. It transforms a standard Vite project into a self-contained userscript bundle, injecting the required metadata header, handling external dependencies via CDN (@require/@resource), and automatically collecting GM API grants. The plugin supports both development (HMR via a proxy server) and production builds, with dynamic import support via SystemJS. It consists of a collection of Rollup/Vite plugins that modify the build pipeline: config, CSS injection, external globals, external resources, asset URL fixing, and final bundle generation. The architecture is modular and well-separated, with clean abstractions for userscript metadata generation, AST-based grant collection, and CDN URL helpers.