A Vite plugin that focuses on generating packaging information for Git projects.
English | 中文
Get the version
information from package.json
, then automatically put the version file version.json
in your project dist folder when packaging.
// package.json
{
// ...
"name": "vite-plugin-git-version",
"version": "1.0.0"
}
// dist/version.json
{
"name": "vite-plugin-git-version",
"version": "1.0.0",
"branch": "(HEAD -> main, origin/main, origin/HEAD)",
"hash": "3e85fdd2e0aeac7685e3d20da16ff979440cbcb8",
"commitUser": "xkloveme (xkloveme@gmail.com)",
"commitContent": "chore: 更新README和package.json中的依赖信息\n更新版本\nchore: release v1.0.4",
"time": "2024-08-09 22:13:11"
}
pnpm add vite-plugin-git-version
yarn add vite-plugin-git-version
npm i vite-plugin-git-version
Add plugin to your vite.config.ts
or vite.config.js
:
// vite.config.ts
import { defineConfig } from 'vite'
import VersionGitPlugin from 'vite-plugin-git-version'
export default defineConfig({
plugins: [
VersionGitPlugin(),
],
})