Registry / devops / vite-plugin-archiver

vite-plugin-archiver

JSON →
library0.3.2jsnpmunverified

A Vite plugin that archives the build output into a ZIP or TAR file after a successful build. Current stable version 0.3.2, released sporadically with no fixed cadence. Only supports ESM imports. Key differentiator: integrates deeply with Vite's build lifecycle and uses archiver.js for archive creation, with options for output type, compression level, filename templates (using dayjs), and auto-open of archive directory. Requires Vite 6/7/8. Ships TypeScript types. Lightweight with no other runtime dependencies.

npm install vite-plugin-archiver
INSTALL
IMPORT
SIG · VITE-PLUGIN-ARCHIV
V
vite-plugin-archiver
devopsjavascriptv0.3.2
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.

default
import ArchiverPlugin from 'vite-plugin-archiver'
const ArchiverPlugin = require('vite-plugin-archiver')
Module is ESM-only; CommonJS require() will fail. Default export is the plugin function.
default (with type)
import type { VitePluginArchiverOptions } from 'vite-plugin-archiver'
TypeScript users should import the options type for type safety. The default export is still the plugin.
plugin usage in vite.config.ts
import { defineConfig } from 'vite'; import ArchiverPlugin from 'vite-plugin-archiver'; export default defineConfig({ plugins: [ArchiverPlugin({ archiveType: 'zip' })] })
export default defineConfig({ plugins: [ArchiverPlugin({ archiveType: 'zip' }).plugin] // No .plugin property })
The plugin is a function that returns a Vite plugin object; no need to access a subproperty.

Quick setup of vite-plugin-archiver with ZIP output, custom name template, and compression options.

// install: npm i vite-plugin-archiver -D // vite.config.ts import { defineConfig } from 'vite' import ArchiverPlugin from 'vite-plugin-archiver' export default defineConfig({ build: { outDir: 'dist' }, plugins: [ ArchiverPlugin({ archiveType: 'zip', // 'zip' or 'tar' archiveZipOptions: { zlib: { level: 9 } // compression level (0-9) }, formatTemplate: 'YYYY-MM-DD-HH-mm-ss', // date-based filename open: false // auto-open archive directory? }) ] }) // After build, creates dist/2025-03-25-12-00-00.zip (or .tar)
Debug
Known issues
breakingSince v0.3.0, Vite 6+ is required; Vite 5 and below are no longer supported.
fix
Upgrade Vite to ^6.0.0 || ^7.0.0 || ^8.0.0; or pin plugin to v0.2.x for Vite 5 support.
affects: >=0.3.0
breakingSince v0.2.0, the plugin is ESM-only. CommonJS require() will throw an error.
fix
Use import instead of require, and ensure your project is configured for ESM (e.g., "type": "module" in package.json).
affects: >=0.2.0
gotchaThe default archive directory is Vite's build.outDir. If outDir is not set, it defaults to 'dist'. Make sure outDir exists or is created during build.
fix
Explicitly set build.outDir in Vite config, or ensure the output directory is generated by Vite.
affects: >=0.1.0
gotchaThe formatTemplate uses dayjs formatting tokens. If you include invalid tokens (e.g., 'YYYY' is valid, but 'YYY' is not), the archive filename will have unexpected characters.
fix
Use dayjs-compatible format tokens: YYYY, MM, DD, HH, mm, ss, etc.
affects: >=0.1.0
gotchaThe 'open' option is intended to open the archive directory after build. This may not work in headless CI environments or on all operating systems.
fix
Set open: false in CI environments, or use an environment variable to conditionally enable it.
affects: >=0.1.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module
Using CommonJS require() to load the plugin in a CJS project.
fix
Switch to import syntax or set "type": "module" in package.json. If using TypeScript, ensure esModuleInterop is enabled.
TypeError: ArchiverPlugin is not a function
Default import assumed the plugin is an object with a 'plugin' property, but the module exports a function directly.
fix
Use ArchiverPlugin directly as a function: plugins: [ArchiverPlugin({...})]
Error: Cannot find module 'vite'
Vite is not installed or version mismatched (plugin requires Vite 6/7/8).
fix
Install a compatible Vite version: npm install vite@^6.0.0
Error: Invalid archive type: 'tgz'. Supported types are 'zip' and 'tar'.
Passing an unsupported archive type like 'tgz' (should be 'tar' for gzipped tar).
fix
Use archiveType: 'tar' and optionally set archiveTarOptions.gzip: true.
Upgrade
Version history
0.3.2latest on npm
Audit
Dependencies
viterequiredPlugin designed to work as a Vite plugin, requires Vite 6/7/8
Agent activity
12 hits · last 30 days
node
10
Amazon
1
Resources
vite-plugin-archiver — npm install vite-plugin-archiver · libregistry