# @serguun42/webpack-userscript-plugin

> A plugin used build userscripts with Webpack

Latest version **1.0.1** (published 2022-12-07) · BSL-1.0 license · 0 weekly downloads

## Install

```sh
npm install @serguun42/webpack-userscript-plugin
pnpm add @serguun42/webpack-userscript-plugin
yarn add @serguun42/webpack-userscript-plugin
bun add @serguun42/webpack-userscript-plugin
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-12-07 |
| First published | 2022-11-30 |
| Weekly downloads | 0 |
| License | BSL-1.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | serguun42 |
| Maintainers | serguun42 |
| Keywords | webpack, userscript |

## Links

- npm: https://www.npmjs.com/package/@serguun42/webpack-userscript-plugin
- Repository: https://github.com/serguun42/webpack-userscript-plugin
- Issues: https://github.com/serguun42/webpack-userscript-plugin/issues
- npm.io page: https://npm.io/package/@serguun42/webpack-userscript-plugin

## Dependencies (1)

- [webpack-sources](https://npm.io/package/webpack-sources.md) ^3.2.3

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2022-12-07
- 1.0.0 — 2022-11-30

## README

# Webpack Userscript Plugin

Appends generated script with Userscript metadata. Continuation of [`serguun42-webpack-userscript`](https://github.com/serguun42/serguun42-webpack-userscript) which itself was a fork of [webpack-userscript package by MomoCow](https://github.com/momocow/webpack-userscript). Supports webpack of versions 4+ and 5+.

## Usage

Suitable for _webpack v4_ and _webpack v5_. From `package.json`:

```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`_):

```javascript
const WebpackUserscriptPlugin = require("@serguun42/webpack-userscript-plugin");

module.exports = {
  entry: "…",
  output: {
    path: "…",
    filename: "…",
  },
  …
  plugins: [
    …,
    new WebpackUserscriptPlugin(pluginOption),
    …
  ]
}
```

### Config/params

Add plugin with constructor:

```javascript
new WebpackUserscriptPlugin(pluginOption);
```

Where `pluginOption` is object of type [`WebpackUserscriptPluginOptions`](./types/index.d.ts#L37) with following props:

| name      | description/type                                                                                                                          | default      |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
| `headers` | `string` for location of `.json` file with headers or object with metadata fields (of type [`UserscriptMetadata`](./types/index.d.ts#L3)) | **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](https://www.tampermonkey.net/documentation.php)
- [Metadata block for Violentmonkey](https://violentmonkey.github.io/api/metadata-block/)
- [Metadata block on greasespot.net](https://wiki.greasespot.net/Metadata_Block)
- [webpack-userscript package by MomoCow](https://github.com/momocow/webpack-userscript)
- [generate-file-webpack-plugin by kflGALORE](https://github.com/kflGALORE/generate-file-webpack-plugin/blob/master/src/index.ts#L24)
- [workbox by GoogleChrome](https://github.com/GoogleChrome/workbox/blob/v6/packages/workbox-webpack-plugin/src/generate-sw.ts#L110)

---

### [BSL-1.0 License](./LICENSE)

---
_Source: https://npm.io/package/@serguun42/webpack-userscript-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
