# vite-plugin-zip-file

> Zip files at build time.

Latest version **5.0.1** (published 2026-06-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install vite-plugin-zip-file
pnpm add vite-plugin-zip-file
yarn add vite-plugin-zip-file
bun add vite-plugin-zip-file
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.0.1 |
| Published | 2026-06-08 |
| First published | 2022-08-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | Shawn Wu |
| Maintainers | ssis53 |
| Keywords | vite-plugin, vite, zip, compress |

## Links

- npm: https://www.npmjs.com/package/vite-plugin-zip-file
- Repository: https://github.com/Ssis53/vite-plugin-zip
- Homepage: https://github.com/Ssis53/vite-plugin-zip#readme
- Issues: https://github.com/Ssis53/vite-plugin-zip/issues
- npm.io page: https://npm.io/package/vite-plugin-zip-file

## Dependencies (1)

- [jszip](https://npm.io/package/jszip.md) 3.10.1

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 5.0.1 (latest) — 2026-06-08
- 5.0.0 — 2026-01-20
- 4.1.1 — 2025-09-01
- 4.1.0 — 2025-04-03
- 4.0.0 — 2025-04-01
- 3.1.2 — 2024-10-29
- 3.1.1 — 2024-10-29
- 3.1.0 — 2024-06-06
- 3.0.0 — 2024-04-01
- 2.2.0 — 2023-11-13
- 2.1.1 — 2023-07-19
- 2.1.0 — 2023-07-04
- 2.0.0 — 2023-03-17
- 1.1.0 — 2022-11-18
- 1.0.3 — 2022-10-30
- … 3 more at https://npm.io/package/vite-plugin-zip-file/versions

## README

# vite-plugin-zip-file

![Vite compatibility](https://registry.vite.dev/api/badges?package=vite-plugin-zip-file&tool=vite)
[![MIT LICENSE](https://img.shields.io/badge/LICENSE-MIT-green)](./LICENSE)
 ![size](https://img.shields.io/bundlephobia/min/vite-plugin-zip-file)
[![downloads](https://img.shields.io/npm/dw/vite-plugin-zip-file)](https://www.npmjs.com/package/vite-plugin-zip-file)

Zip files at build time.

**Tips: Node.js 20+ is required.**

# Install

```
yarn add vite-plugin-zip-file --dev
```

or

```
npm install vite-plugin-zip-file --save-dev
```

or

```
pnpm add vite-plugin-zip-file -D
```

# Options


| Params            | Types        | Rquired | Default | Desc                                                         |
| :---------------- | ------------ | ------- | ------- | ------------------------------------------------------------ |
| folderPath        | String\|Path | true    | /dist   | Path to the compressed folder                                |
| outPath           | String\|Path | true    | /       | Compressed package output path                               |
| zipName           | String       | false   | dist    | Package name                                                 |
| enabled           | Boolean      | false   | true    | This parameter is used to control whether the plugin is enabled. It is usually used to determine whether to compress files according to the environment |
| deleteFolder      | Boolean      | false   | false   | Whether to delete source files after compression is completed |
| withoutMainFolder | Boolean      | false   | false   | The compressed file whether removes the outermost main folder. |

<br />

# 选项

<table>
  <thead>
    <tr>
      <th>参数</th>
      <th>类型</th>
      <th width="75">必填</th>
      <th width="95">默认值</th>
      <th>说明</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>folderPath</td>
      <td>String|Path</td>
      <td>是</td>
      <td>/dist</td>
      <td>需要被压缩的源文件夹</td>
    </tr>
    <tr>
      <td>outPath</td>
      <td>String|Path</td>
      <td>是</td>
      <td>/</td>
      <td>压缩包输出路径</td>
    </tr>
    <tr>
      <td>zipName</td>
      <td>String</td>
      <td>否</td>
      <td>dist</td>
      <td>压缩包名称</td>
    </tr>
    <tr>
      <td>enabled</td>
      <td>Boolean</td>
      <td>否</td>
      <td>true</td>
      <td>用于控制插件是否启用， 通常用于根据环境判断是否压缩文件</td>
    </tr>
    <tr>
      <td>deleteFolder</td>
      <td>Boolean</td>
      <td>否</td>
      <td>false</td>
      <td>压缩完成后是否删除源文件</td>
    </tr>
    <tr>
      <td>withoutMainFolder</td>
      <td>Boolean</td>
      <td>否</td>
      <td>false</td>
      <td>压缩后的文件是否去掉最外层文件夹</td>
    </tr>
  </tbody>
</table>

<br />

# Usage

```javascript
import { defineConfig } from 'vite';
import { viteZip } from 'vite-plugin-zip-file';
import path from 'path';
import { fileURLToPath } from 'url';
import { env } from 'node:process';
const __dirname = path.dirname(fileURLToPath(import.meta.url));

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    viteZip({
      folderPath: path.resolve(__dirname, 'dist'),
      outPath: path.resolve(__dirname),
      zipName: 'dist.zip',
      enabled: env.NODE_ENV === 'production'? true: false
    })
  ]
})
```

---
_Source: https://npm.io/package/vite-plugin-zip-file · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
