# @metamask/snaps-webpack-plugin

> A Webpack plugin to build MetaMask Snaps with Webpack

Latest version **5.1.2** (published 2026-01-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install @metamask/snaps-webpack-plugin
pnpm add @metamask/snaps-webpack-plugin
yarn add @metamask/snaps-webpack-plugin
bun add @metamask/snaps-webpack-plugin
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.1.2 |
| Published | 2026-01-22 |
| First published | 2022-05-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^20 \|\| >=22 |
| Dependencies | 7 |
| Unpacked size | 66.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 856 |
| Maintainers | danfinlay, kumavis, metamaskbot |
| Keywords | MetaMask, Snaps, Ethereum, Webpack, Plugin |

## Links

- npm: https://www.npmjs.com/package/@metamask/snaps-webpack-plugin
- Repository: https://github.com/MetaMask/snaps
- Homepage: https://github.com/MetaMask/snaps/tree/main/packages/snaps-webpack-plugin#readme
- Issues: https://github.com/MetaMask/snaps/issues
- npm.io page: https://npm.io/package/@metamask/snaps-webpack-plugin

## Dependencies (7)

- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [prettier](https://npm.io/package/prettier.md) ^3.3.3
- [@metamask/utils](https://npm.io/package/@metamask/utils.md) ^11.9.0
- [webpack-sources](https://npm.io/package/webpack-sources.md) ^3.2.3
- [@metamask/snaps-sdk](https://npm.io/package/@metamask/snaps-sdk.md) ^10.4.0
- [@metamask/snaps-utils](https://npm.io/package/@metamask/snaps-utils.md) ^12.0.0
- [@metamask/snaps-rpc-methods](https://npm.io/package/@metamask/snaps-rpc-methods.md) ^14.2.0

## 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

- 5.1.2 (latest) — 2026-01-22
- 0.37.4-flask.1 (flask) — 2023-09-20
- 1.0.0-prerelease.1 (next) — 2023-06-23
- 5.1.1 — 2025-10-02
- 5.1.0 — 2025-08-06
- 5.0.0 — 2025-06-27
- 4.3.0 — 2025-05-27
- 4.2.1 — 2025-01-14
- 4.2.0 — 2024-12-17
- 4.1.2 — 2024-09-12
- 4.1.1 — 2024-09-11
- 4.1.0 — 2024-07-31
- 4.0.1 — 2024-02-27
- 4.0.0 — 2024-02-26
- 3.2.0 — 2024-02-16
- … 54 more at https://npm.io/package/@metamask/snaps-webpack-plugin/versions

## README

# @metamask/snaps-webpack-plugin

A plugin for developing [MetaMask Snaps](https://docs.metamask.io/guide/snaps.html) using [Webpack](https://webpack.js.org/). This can be used as alternative to the `mm-snap` CLI `build` command. It transforms the bundle to fix common issues with SES. For a list of changes the plugin makes, you can refer to [the source code](../utils/src/post-process.ts).

## Installation

Use Node.js `16.0.0` or later. We recommend using [nvm](https://github.com/nvm-sh/nvm) for managing Node.js versions.

Install a dependency in your snap project using `yarn` or `npm`:

- `npm install @metamask/snaps-webpack-plugin`
- `yarn add @metamask/snaps-webpack-plugin`

## Usage

Add the plugin to the `plugins` array in your Webpack configuration:

```ts
// webpack.config.js

import SnapsWebpackPlugin from '@metamask/snaps-webpack-plugin';

export default {
  plugins: [new SnapsWebpackPlugin(options)],
};
```

### Options

All options are optional, and default to `true`.

```ts
import { Options } from '@metamask/snaps-webpack-plugin';

const options: Options = {
  /**
   * Whether to strip all comments from the bundle.
   */
  stripComments: true,

  /**
   * Whether to evaluate the bundle with SES, to ensure SES compatibility.
   */
  eval: true,

  /**
   * The path to the Snap manifest file. If set, it will be checked and automatically updated with
   * the bundle's hash, if `writeManifest` is enabled. Defaults to `snap/manifest.json` in the
   * current working directory.
   */
  manifestPath: './snap.manifest.json',

  /**
   * Whether to write the updated Snap manifest file to disk. If `manifestPath` is not set, this
   * option has no effect. If this is disabled, an error will be thrown if the manifest file is
   * invalid.
   */
  writeManifest: true,
};
```

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