Registry / devops / zip-webpack-plugin

zip-webpack-plugin

JSON →
library4.0.3jsnpmunverified

Webpack plugin that compresses all emitted assets into a single zip file. Current stable version is 4.0.3, supporting Webpack 4 and 5 (and Rspack experimentally). It uses yazl for zip creation and offers options for path prefix, filename, extension, include/exclude filters, and compression control. Compared to alternatives like `webpack-plugin-zip`, it is lightweight, well-maintained, and straightforward. Release cadence is sporadic; major versions introduce breaking changes for Webpack major upgrades.

npm install zip-webpack-plugin
INSTALL
IMPORT
SIG · ZIP-WEBPACK-PLUGIN
Z
zip-webpack-plugin
devopsjavascriptv4.0.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ZipPlugin
const ZipPlugin = require('zip-webpack-plugin');
import ZipPlugin from 'zip-webpack-plugin';
Package is CommonJS-only; ESM import may fail in strict ESM environments.
new ZipPlugin({...})
plugins: [new ZipPlugin({ filename: 'out.zip' })]
plugins: [ZipPlugin({ filename: 'out.zip' })]
ZipPlugin must be instantiated with 'new'. Forgetting 'new' will not throw but will cause undefined behavior.
path
const path = require('path');
path is not imported
Required if using path.join in pathMapper or other path operations in configuration.

Shows typical Webpack 5 configuration with ZipPlugin: entry, output, and plugin options for filtering assets, setting path prefix, and compression.

const path = require('path'); const ZipPlugin = require('zip-webpack-plugin'); module.exports = { mode: 'production', entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js' }, plugins: [ new ZipPlugin({ filename: 'app.zip', pathPrefix: 'static/', include: [/\\.js$/, /\\.css$/], exclude: [/\\.map$/], fileOptions: { compress: true, mtime: new Date() }, zipOptions: { forceZip64Format: false } }) ] };
Debug
Known issues
breakingv4.0.0 drops support for Node < 10.
fix
Upgrade to Node >= 10 or stay on v3.x (which supports Node 8+).
affects: >=4.0.0
breakingv3.0.0 drops Webpack 3 support; requires Webpack 4+.
fix
For Webpack 3, use v2.0.0: npm install zip-webpack-plugin@2.0.0
affects: >=3.0.0
gotchaWhen using Webpack 5, the plugin runs at a later stage to pick up changes from other plugins (v4.0.1+). In earlier v4.x, some plugin modifications might be missed.
fix
Upgrade to v4.0.1 or later.
affects: >=4.0.0 <4.0.1
deprecatedThe 'path' option can be relative to the Webpack output path. In v4, absolute paths are also allowed, but relative paths are the most common pattern.
fix
No fix needed; just ensure the path is correct.
affects: >=4.0.0
gotchaThe plugin does not work with Webpack 5's persistent caching by default; assets may not be zipped on cache hits.
fix
Explicitly disable persistent caching or ensure the plugin re-runs (e.g., using cache.version).
affects: >=4.0.0
Errors
Common errors & fixes
Error: Cannot find module 'zip-webpack-plugin'
Package not installed or missing in node_modules.
fix
Run `npm install --save-dev zip-webpack-plugin` in the project root.
TypeError: ZipPlugin is not a constructor
ZipPlugin imported incorrectly or not instantiated with 'new'.
fix
Use `const ZipPlugin = require('zip-webpack-plugin');` then `new ZipPlugin({...})` in plugins array.
ValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration.plugins[0] should be a function.
Forgot to instantiate ZipPlugin with 'new'.
fix
Change `plugins: [ZipPlugin({...})]` to `plugins: [new ZipPlugin({...})]`.
Upgrade
Version history
4.0.3latest on npm
Audit
Dependencies
webpackrequiredPeer dependency; plugin runs within Webpack compilation lifecycle.
webpack-sourcesrequiredPeer dependency; used for asset source handling (RawSource in Webpack 5).
Agent activity
29 hits · last 30 days
node
24
Resources
zip-webpack-plugin — npm install zip-webpack-plugin · libregistry