Vite plugin that generates VERSION and COMMITHASH files during build based on a local git repository.
npm install @jinixx/vite-plugin-git-revision

> Git version info for applications using Vite
>
> Forked from https://github.com/qduld/vite-plugin-git-revision to fix a few issues.
Install:
``bash`
npm install -D @jinixx/vite-plugin-git-revision
Add to your vite.config.js:
`js
import GitRevision from 'vite-plugin-git-revision';
export default {
plugins: [
GitRevision()
],
};
`
To use custom configuration, pass your options to Pages when instantiating the plugin:
`js
// vite.config.js
import GitRevision from 'vite-plugin-git-revision';
export default {
plugins: [
GitRevision({
lightweightTags: false,
branch: false,
// default, remove prop if not needed, do not set to empty
commithashCommand: 'rev-parse HEAD',
// default versionCommand was describe --always`
versionCommand: 'describe --tags --long --dirty --always',
// default, remove prop if not needed, do not set to empty
branchCommand: 'rev-parse --abbrev-ref HEAD',
// change the default git command used to read the DATE and TIME of the commit
datetimeCommand: 'log -1 --date=format:"%Y-%m-%d %H:%M" --pretty=format:'%ad'',
}),
],
};
- Type: booleanfalse
- Default:
lightweight tags support.
- Type: booleanfalse
- Default:
branch tags support.
- Type: stringdescribe --always
- Default:
change the default git command used to read the value of VERSION.
- Type: stringrev-parse HEAD
- Default:
change the default git command used to read the value of COMMITHASH.
- Type: stringrev-parse --abbrev-ref HEAD
- Default:
change the default git command used to read the value of BRANCH.
- Type: stringlog -1 --date=format:"%Y-%m-%d %H:%M" --pretty=format:'%ad'
- Default:
change the default git command used to read the date and time of the commit.
`js``
// Anywhere in your application code
console.log(GITVERSION);
console.log(GITCOMMITDATETIME);
MIT