A Vite plugin that injects git repository information (commit hash, version, branch, last commit datetime) as global constants at build time. Current stable version is 0.0.11, with experimental release cadence. Inspired by git-revision-webpack-plugin, it aims to provide equivalent functionality for Vite projects. Lightweight and zero-config by default, it exposes four globals: GIT_COMMITHASH, GIT_VERSION, GIT_BRANCH, GIT_LASTCOMMITDATETIME. Supports custom variable names, git commands, and lightweight tags. TypeScript types are included.
npm install git-revision-vite-pluginVerified import paths — ran on the pinned version, not inferred.
Shows plugin setup and usage of injected git globals in a Vue component.
Ensure you use these variables only in code that is processed by Vite (e.g., inside Vue SFCs or imported modules) and not in external scripts.
If using lightweightTags, do not set versionCommand explicitly. Set version: false if not needed.
Upgrade to 0.0.2 or later to use custom variable names.
Update any references to the old global names to the new ones: GIT_COMMITHASH, GIT_VERSION, GIT_BRANCH, GIT_LASTCOMMITDATETIME.
Remove versionCommand when lightweightTags: true, or set lightweightTags: false.
Only use these globals inside files processed by Vite (like .vue, .tsx, .js imported in src). They are compile-time constants.
Use default import: import GitRevisionVitePlugin from 'git-revision-vite-plugin'.
No dependency data recorded yet.