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

version-maker

v0.1.10

Published

Write a minimal build stamp file with version and release time.

Downloads

2

Readme

version-maker(Vite 集成)

一个极简、零依赖的构建标记工具,用于在 Vite 构建时自动:

  • 写入文件:dist/version.txt(包含 versionreleased_at
  • 注入环境变量:
    • import.meta.env.VER_MAKER_APP_VERSION
    • import.meta.env.VER_MAKER_APP_RELEASED_AT

行为约定:

  • 开发模式(vite dev):不生成新时间、不写文件,VER_MAKER_APP_RELEASED_AT 读取上次 build 的值(若无则为 N/A)。
  • 构建模式(vite build):可选自动升级版本(autoBump),生成新的时间并写入文件,同时注入两个环境变量。

安装

npm i -D version-maker

Vite 插件使用

vite.config.js

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import buildStamp from 'version-maker/vite'

export default defineConfig({
  plugins: [
    vue(),
    buildStamp({
      // 输出文件(构建完成后写入两行:version 与 released_at)
      out: 'dist/version.txt',
      // 时间格式与时区(人类可读部分)
      timezone: 'Asia/Shanghai',         // 可选 'UTC' 或其他 IANA 时区
      timeFormat: 'YYYY-MM-DD HH:mm:ss Z',
      // 构建时是否自动升级版本(默认 true),及升级级别
      autoBump: true,
      bump: 'patch'                      // 可选 'patch' | 'minor' | 'major'
    })
  ]
})

环境变量(插件直接注入)

  • import.meta.env.VER_MAKER_APP_VERSIONpackage.json.version(构建时如启用 autoBump,为升级后的版本)
  • import.meta.env.VER_MAKER_APP_RELEASED_AT:形如 1731307200000[2025-11-11 12:00:00 +08:00]
    • 左侧为毫秒级 Unix 时间戳
    • [] 内为人类可读时间(按 timezonetimeFormat 格式化)
    • 开发模式下读取上次 build 的值,若不存在则为 N/A

前端代码示例

console.info('[version-maker] VER_MAKER_APP_VERSION:', import.meta.env.VER_MAKER_APP_VERSION)
console.info('[version-maker] VER_MAKER_APP_RELEASED_AT:', import.meta.env.VER_MAKER_APP_RELEASED_AT)

构建输出验证

  • 运行构建:npm run build
  • 查看文件:dist/version.txt,内容示例:
    version: 0.1.3
    released_at: 1731307200000[2025-11-11 12:00:00 +08:00]

说明:

  • 两行内容对应同一时刻,released_at 的时间戳与格式化时间是一致的。
  • 构建期间注入的 VER_MAKER_APP_VERSIONVER_MAKER_APP_RELEASED_AT 与文件写入值保持一致。