Package Exports
- @serguun42/webpack-userscript-plugin
- @serguun42/webpack-userscript-plugin/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@serguun42/webpack-userscript-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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