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-git-stamp

v1.0.2

Published

A Vite plugin to stamp build artifacts with Git version info including branch, commit hash, commit message, author, latest tag, and build time.

Readme

vite-plugin-git-stamp

简介

vite-plugin-git-stamp 是一个 Vite 插件,用于在构建产物中记录 Git 版本信息,包括分支名称、提交哈希、提交信息、提交作者、最新标签以及构建时间等信息。通过将这些信息写入构建目录下的 JSON 文件,你可以方便地追溯每个构建产物对应的源代码版本,从而更好地进行版本管理和问题排查。

功能特性

  • 自动采集 Git 相关信息:
    • 分支名称
    • 提交哈希
    • 提交信息
    • 提交作者
    • 最新标签
    • 构建时间
  • 在 Vite 构建过程中自动生成包含以上信息的 JSON 文件
  • 支持 Windows、Linux 和 macOS 等操作系统(前提是系统中安装了 Git 并且 Git 命令可在 PATH 中使用)

安装

使用 npm 或 yarn 将插件安装为开发依赖:

npm install --save-dev vite-plugin-git-stamp

或者

yarn add --dev vite-plugin-git-stamp

使用方法

在你的 Vite 配置文件中引入并使用该插件。例如,在 vite.config.js 中这样配置:

// vite.config.js
import { defineConfig } from 'vite';
import gitStampPlugin from 'vite-plugin-git-stamp';

export default defineConfig({
  plugins: [
    gitStampPlugin({
      // 可选配置项
      outDir: 'dist',           // 输出目录,默认为 'dist'
      fileName: 'version.json'   // 输出文件名称,默认为 'version.json'
    })
  ],
});

执行 vite build 后,将在指定的输出目录(默认是 dist)中生成一个 JSON 文件(默认名称为 version.json),文件中包含了 Git 相关的版本信息。

插件选项

该插件接受一个选项对象,支持以下属性:

  • outDirstring
    构建产物输出目录,默认为 'dist'

  • fileNamestring
    输出的 JSON 文件名称,默认为 'version.json'

兼容性与注意事项

  • 跨平台支持
    本插件基于 Node.js 内置模块开发,理论上可在 Windows、Linux、macOS 等操作系统上运行。但需要确保系统中已安装 Git,并且 Git 命令能够在终端中正常使用。

  • CI/CD 环境
    在某些 CI/CD 环境中,如果使用了浅克隆(shallow clone)或者 Git 仓库数据不全,部分 Git 命令可能无法获取预期的信息。请根据实际情况调整 Git 克隆策略或通过环境变量补充相应信息。

  • 权限问题
    请确保输出目录具有写入权限,否则在生成版本信息文件时可能会出现写入失败的情况。

许可证

该项目采用 MIT License 开源许可证。