@jswork/vite-plugin-html-build-stamp
v1.0.2
Published
Inject lightweight build stamp comment into html for vite app.
Readme
vite-plugin-html-build-stamp
Inject lightweight build stamp comment into html for vite app.
installation
npm install @jswork/vite-plugin-html-build-stampusage
import { defineConfig } from 'vite';
import vitePluginHtmlBuildStamp from '@jswork/vite-plugin-html-build-stamp';
export default defineConfig({
plugins: [vitePluginHtmlBuildStamp()],
});Injected comment (top of index.html, build only by default):
<!--
* name: frontend
* version: 2.1.0
* build_time: 2026-11-06 12:38:09
* build_hash: 3fa2c71d
* git_commit: a7f2c71
* git_branch: main
-->options
| option | type | default | description |
|---|---|---|---|
| fields | string[] | all 6 | Whitelist of injected fields (order fixed: name, version, build_time, build_hash, git_commit, git_branch) |
| enable | boolean | true | Master switch |
| enableInDev | boolean | false | Also inject during dev server |
field sources
name/version:package.jsonbuild_time: local time,YYYY-MM-DD HH:mm:ssbuild_hash: hash of collected bundle filename hashes (falls back to content hash in dev)git_commit/git_branch: CI env vars first (GitLab CI, GitHub Actions), then localgit. Missing → line omitted.
license
Code released under the MIT license.
