1.0.1 • Published 1 year ago

@serguun42/webpack-userscript-plugin v1.0.1

Weekly downloads
-
License
BSL-1.0
Repository
github
Last release
1 year ago

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"
}
  1. Install – npm i @serguun42/webpack-userscript-plugin.
  2. 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:

namedescription/typedefault
headersstring for location of .json file with headers or object with metadata fields (of type UserscriptMetadata)required
prettyPrettify headers with even space or nottrue
metajsCreate additional .meta.js file (in the same output directory) with headers onlyfalse

See also


BSL-1.0 License