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-build-pack

v1.0.0

Published

Vite plugin: clean output by glob, zip build dir (name-version.zip), auto-increment version in build.config.json

Readme

vite-plugin-build-pack

Vite 插件:打包完成后清理输出目录指定文件(支持 glob)、自动打 zip(如 name-0.0.0.zip)、版本号自增(每次打包末位 +1,写回 build.config.json)。也可仅使用清理能力。

安装

npm i vite-plugin-build-pack
# or
pnpm add vite-plugin-build-pack
# or
yarn add vite-plugin-build-pack

一、打包 + 压缩(buildPack)

打包成功后自动生成 {name}-{version}.zip,每次打包将版本末位 +1 并写回 build.config.json

1. 项目根目录配置文件(推荐)

在项目根目录新建 build.config.json

{
  "name": "my-app",
  "version": "0.0.0",
  "cleanOutput": {
    "patterns": ["**/.DS_Store", "**/index.html"],
    "verbose": true
  }
}
  • name(可选):zip 文件名前缀。不配置则使用打包输出目录名(如 distdist-admin-renda-meet-flow)。
  • version(可选):版本,默认 "0.0.0"。每次打包后末位 +1 并写回本文件。
  • cleanOutput(可选):打包前/后按 glob 删除输出目录中的文件。

vite.config.ts 中:

import { defineConfig } from 'vite'
import { buildPack } from 'vite-plugin-build-pack'

export default defineConfig({
  plugins: [
    buildPack({ configPath: 'build.config.json' }),
  ],
})

2. 全部在 Vite 里配置

也可以不建 build.config.json,在插件参数里写完整配置:

buildPack({
  name: 'my-app',         // 可选,默认用输出目录名
  version: '0.0.0',       // 可选,默认 0.0.0
  configPath: 'build.config.json', // 可选,版本在此文件中读写
  zip: true,              // 可选,是否打 zip,默认 true
  cleanOutput: {
    patterns: ['**/.DS_Store', '**/*.map'],
    verbose: true,
  },
}),

行为说明

  1. name:未配置时用 config.build.outDir 的目录名(如 dist → zip 名为 dist-0.0.0.zip)。
  2. version:从 build.config.json 读取,默认 "0.0.0";每次打包后末位 +1 并写回该文件。
  3. zip 生成在项目根目录,如 my-app-0.0.1.zip

二、仅清理输出(cleanOutput)

只做「按 glob 删除输出目录文件」,不打 zip、不碰版本:

import { cleanOutput } from 'vite-plugin-build-pack'

cleanOutput({
  patterns: ['**/.DS_Store', '**/*.map'],
  verbose: true,
}),

Glob 模式

  • **:任意层级目录
  • *:单层
  • ?[a-z]{a,b} 等均支持

示例:**/.DS_Store**/*.map**/index.html

发布到 npm

cd vite-plugin-build-pack
pnpm install
pnpm run build
npm publish

License

MIT