npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-plugin-zip-plus

v1.0.6

Published

a vite plugin which can zip special dir or files to anywhere you want.

Readme

vite-plugin-zip-plus

一个 Vite 插件,用于将指定的构建输出文件打包为 ZIP 格式。支持 Glob 模式、正则表达式和自定义函数匹配规则,适用于源码过滤、产物筛选等场景。

🔧 功能特点

  • ✅ 支持将构建产物打包为 ZIP 文件
  • ✅ 支持多种匹配方式:Glob 模式 / 正则表达式 / 自定义函数
  • ✅ 支持构建后文件名匹配和排除(includeexclude
  • ✅ 可配置压缩算法(如 DEFLATE)
  • ✅ 支持保留原始路径结构
  • ✅ 支持清理并重新创建输出目录

📦 安装

npm install vite-plugin-zip-plus --save-dev

🛠️ 使用方法

// vite.config.js
import { defineConfig } from 'vite'
import zipPlus from 'vite-plugin-zip-plus'

export default defineConfig({
  plugins: [
    zipPlus({
      outputDir: 'dist',          // 输出 ZIP 的存放目录
      zipFileName: 'output.zip',  // ZIP 文件名
      include: '**/*',            // 构建后匹配规则(默认包含所有文件)
      exclude: null,              // 构建后排除规则(默认不排除任何文件)
      compression: 'DEFLATE',     // 压缩算法(可选:STORE/DEFLATE)
      preservePaths: false        // 是否在 ZIP 中保留原始路径
    }),
  ],
})

📋 配置项说明

| 参数 | 类型 | 默认值 | 描述 | |------|------|--------|------| | outputDir | string | 'dist' | ZIP 文件输出目录 | | zipFileName | string | 'output.zip' | ZIP 文件名 | | include | string | RegExp | Function | '**/*' | 构建后匹配规则) | | exclude | string | RegExp | Function | null | 构建后排除规则 | | compression | string | 'DEFLATE' | 压缩算法(DEFLATESTORE) | | preservePaths | boolean | false | 是否在 ZIP 中保留原始路径 |

💡 includeexclude 支持以下格式:

  • string: Glob 模式,如 'src/**/*.ts'
  • RegExp: 正则表达式,如 `/.js+$/
  • Function: 自定义判断函数,如 (id) => id.includes('main')

🧪 示例用法

示例 1:只打包 assets 下的 .js 和 .css 文件

zipPlus({
  include: 'assets/*.{js,css}',
})

示例 2:排除所有 .map 文件

zipPlus({
  exclude: /\.map$/i,
})

示例 3:自定义判断函数

zipPlus({
  exclude: (filename) => filename === 'index.html',
})

示例 4:只打包 src 和 assets 目录下的文件

zipPlus({
  include: '{src,assets}/**/*',
})

⚠️ 注意事项

  • 确保运行环境支持 fs/promises(Node.js v14+)
  • ZIP 文件生成是异步操作,确保构建流程完成后再检查输出