Registry / devops / vite-plugin-zip-pack

vite-plugin-zip-pack

JSON →
library1.2.4jsnpmunverified

The `vite-plugin-zip-pack` is a utility for Vite-based projects, designed to automatically compress the build output directory into a single zip archive. Currently at version 1.2.4, this plugin integrates seamlessly into the Vite configuration, executing its archival task as part of the build process. It allows developers to specify custom input and output directories, define the zip archive's filename, and apply a path prefix for the contents within the zip. A key differentiator is its straightforward API and direct integration with Vite's build lifecycle, simplifying deployment preparation by providing a ready-to-distribute archive. It also offers a `filter` function for granular control over which files and directories are included in the archive and a `done` callback for post-archival actions. While no explicit release cadence is documented, as a utility plugin, updates typically align with Vite's major versions or address specific bug fixes. This plugin primarily serves to streamline continuous integration and deployment pipelines by automating the creation of deployable zip packages from Vite builds.

npm install vite-plugin-zip-pack
INSTALL
IMPORT
SIG · VITE-PLUGIN-ZIP-PA
V
vite-plugin-zip-pack
devopsjavascriptv1.2.4
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

zipPack
import zipPack from 'vite-plugin-zip-pack';
const zipPack = require('vite-plugin-zip-pack');
The `require` syntax for CommonJS will not work, as Vite configurations are typically ESM-driven.
defineConfig
import { defineConfig } from 'vite';
While `defineConfig` is not from `vite-plugin-zip-pack`, it is essential for configuring Vite plugins and commonly imported alongside `zipPack`.
Options
import type { Options } from 'vite-plugin-zip-pack';
Importing the `Options` type is useful for TypeScript users to ensure correct plugin configuration.

This quickstart demonstrates how to integrate `vite-plugin-zip-pack` into `vite.config.ts`, showcasing basic configuration options like input/output directories, custom filename, a filter function, and a completion callback.

import { defineConfig } from 'vite'; import zipPack from 'vite-plugin-zip-pack'; export default defineConfig({ plugins: [ zipPack({ // Optional: Specify custom input directory (default: 'dist') inDir: 'build', // Optional: Specify custom output directory for the zip (default: 'dist-zip') outDir: 'archives', // Optional: Specify custom zip archive name (default: 'dist.zip') outFileName: 'my-project-release.zip', // Optional: Filter files/directories to include filter: (fileName, filePath, isDirectory) => { // Exclude specific files or directories if (fileName.includes('temp') || isDirectory && fileName === 'node_modules') { return false; } return true; }, // Optional: Callback after zip creation done: (err) => { if (err) { console.error('Failed to create zip file:', err); } else { console.log('Zip file created successfully!'); } } }), ], });
Debug
Known issues
gotchaIncorrectly configured `inDir` or `outDir` paths can lead to empty zip archives or zip files being placed in unexpected locations. Ensure these paths align with your Vite build output and desired archive destination.
fix
Always verify `inDir` points to your actual build output directory (e.g., 'dist', 'build') and `outDir` is an accessible directory where the zip file should be saved.
affects: >=1.0.0
gotchaMisusing the `filter` option can unintentionally exclude necessary files or directories from your zip archive, leading to incomplete deployments. The filter function should return `true` for files/directories to be included.
fix
Thoroughly test your `filter` logic, especially with complex exclusion/inclusion patterns, to ensure all required assets are present in the final zip file. Start with no filter and incrementally add rules.
affects: >=1.0.0
gotchaFor very large projects, zipping the entire build directory might consume significant memory or CPU resources, potentially slowing down CI/CD pipelines. Excessive logging can also add overhead.
fix
Consider setting `enableLogging: false` in production or CI/CD environments. For extremely large builds, investigate external archiving tools or more granular `filter` configurations to reduce the archive size.
affects: >=1.0.0
Errors
Common errors & fixes
Error: [vite-plugin-zip-pack] 'zipPack' is not a function
Attempting to import `zipPack` using CommonJS `require()` syntax or an incorrect named import in a typical ESM-configured Vite project.
fix
Ensure you are using `import zipPack from 'vite-plugin-zip-pack';` as per ESM standards in your `vite.config.js` or `vite.config.ts`.
Error: ENOENT: no such file or directory, scandir 'path/to/nonexistent/directory'
The `inDir` option is configured to a directory that does not exist or is not accessible, often because the build process hasn't completed or the path is incorrect.
fix
Verify that the `inDir` path correctly points to your Vite build output directory (e.g., 'dist'). Ensure the build command runs successfully *before* the zip plugin attempts to archive the files.
Upgrade
Version history
1.2.4latest on npm
Audit
Dependencies
viterequiredRuntime dependency as a Vite plugin, requires Vite for execution.
Agent activity
2 hits · last 30 days
node
2
Resources
vite-plugin-zip-pack — npm install vite-plugin-zip-pack · libregistry