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-packVerified import paths — ran on the pinned version, not inferred.
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.
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.
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.
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.
Ensure you are using `import zipPack from 'vite-plugin-zip-pack';` as per ESM standards in your `vite.config.js` or `vite.config.ts`.
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.