@serguun42/webpack-userscript-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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:

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


BSL-1.0 License

Readme

Keywords

Package Sidebar

Install

npm i @serguun42/webpack-userscript-plugin

Weekly Downloads

0

Version

1.0.1

License

BSL-1.0

Unpacked Size

14 kB

Total Files

9

Last publish

Collaborators

  • serguun42