Skip to content

Repository files navigation

vite-plugin-monkey

npm package node compatibility

Develop and build userscripts for Tampermonkey, Violentmonkey, Greasemonkey, ScriptCat, and other userscript engines with Vite.

Documentation: https://vite-plugin-monkey.pages.dev/

Features

  • Support Tampermonkey, Violentmonkey, Greasemonkey, ScriptCat, and other userscript engines
  • Inject userscript metadata into the build output
  • Open the development userscript in the default browser when its metadata changes
  • Load external dependencies through userscript @require entries
  • Load external modules through userscript @resource entries
  • Import GM APIs through ESM with type hints
  • Collect the GM APIs used by the code and configure @grant automatically
  • Support top-level await and dynamic imports in a single userscript file
  • Open the built userscript automatically when running Vite preview
  • Support TypeScript and Vite features

Quick Start

Create a userscript project with the scaffolding tool:

pnpm create monkey
# npm create monkey
# yarn create monkey

Choose one of the included templates:

JavaScript TypeScript
empty (only js) empty-ts (only ts)
vanilla (js + css) vanilla-ts (ts + css)
vue vue-ts
react react-ts
preact preact-ts
svelte svelte-ts
solid solid-ts
Initializing a Template

vue-ts

Hot Module Replacement

hmr

Build and Preview

build and preview

Installation

Install the plugin in an existing Vite project:

pnpm add -D vite-plugin-monkey
# npm i -D vite-plugin-monkey
# yarn add -D vite-plugin-monkey

Add vite-plugin-monkey as the last item in the Vite plugin list. See the Getting Started guide for the basic configuration.

About

A vite plugin server and build your.user.js for userscript engine like Tampermonkey, Violentmonkey, Greasemonkey, ScriptCat

Topics

Resources

Stars

2.0k stars

Watchers

8 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages