A webpack plugin for building userscript projects targeting Tampermonkey, Greasemonkey, Violentmonkey, and similar userscript engines. Current stable version is 3.2.3 (Dec 2024), with active maintenance on GitHub. The plugin automatically generates userscript headers from metadata, produces .meta.js files for update checks, and creates proxy scripts to avoid caching during development. Key differentiators: full TypeScript support since v3, multi-entry support, header interpolation, and integrated hot-reload workflow with webpack-dev-server. Requires webpack 5 as a peer dependency.
npm install webpack-userscriptNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Configures webpack-userscript with headers, metadata generation, and proxy script for hot development with webpack-dev-server.
Change `const WebpackUserscript = require('webpack-userscript'); new WebpackUserscript(...)` to `const { UserscriptPlugin } = require('webpack-userscript'); new UserscriptPlugin(...)`.Use `const { UserscriptPlugin } = require('webpack-userscript');` instead of `const UserscriptPlugin = require('webpack-userscript');`.Move `headers.proxyScript` to the top-level `proxyScript` option in `new UserscriptPlugin({ proxyScript: { ... } })`.Ensure the output .meta.js file is served at the URL specified by `@updateURL` header. Use `headers.updateURL` to set it correctly.
Rename your entry file to end with `.user.js`, e.g., `./src/index.user.js`.
Upgrade to v3.2.3 which fixes the bug. Alternatively, ensure at least one chunk is named.
Use `const { UserscriptPlugin } = require('webpack-userscript')` and instantiate with `new UserscriptPlugin({...})`.Ensure your entry file has a `.js` or `.user.js` extension and is valid JavaScript/TypeScript.
Run `npm install webpack-userscript --save-dev` or `yarn add webpack-userscript --dev`.
Use `import { UserscriptPlugin } from 'webpack-userscript'` (named import) instead of default import.