Webpack Userscript Plugin
Appends generated script with Userscript metadata. Continuation of serguun42-webpack-userscript
which itself was a fork of webpack-userscript package by MomoCow. Supports webpack of versions 4+ and 5+.
Usage
Suitable for webpack v4 and webpack v5. From package.json
:
"peerDependencies": {
"webpack": "^4.0.0 || ^5.0.0"
}
- Install –
npm i @serguun42/webpack-userscript-plugin
. - Add to webpack config's plugins section (usually
webpack.config.js
):
const WebpackUserscriptPlugin = require("@serguun42/webpack-userscript-plugin");
module.exports = {
entry: "…",
output: {
path: "…",
filename: "…",
},
…
plugins: [
…,
new WebpackUserscriptPlugin(pluginOption),
…
]
}
Config/params
Add plugin with constructor:
new WebpackUserscriptPlugin(pluginOption);
Where pluginOption
is object of type WebpackUserscriptPluginOptions
with following props:
name | description/type | default |
---|---|---|
headers |
string for location of .json file with headers or object with metadata fields (of type UserscriptMetadata ) |
required |
pretty |
Prettify headers with even space or not | true |
metajs |
Create additional .meta.js file (in the same output directory) with headers only |
false |
See also
- Tampermonkey documentation
- Metadata block for Violentmonkey
- Metadata block on greasespot.net
- webpack-userscript package by MomoCow
- generate-file-webpack-plugin by kflGALORE
- workbox by GoogleChrome