vite-plugin-commit-hash
v1.0.8
Published
Exposes the current commit hash to the codebase
Downloads
2,220
Readme
Vite-Plugin-Commit-Hash
Mini-Plugin used to provide commit hash information to the project. This should work cross-framework just fine.
Installation
pnpm i vite-plugin-commit-hash
- Load the plugin in your
vite.config.js
:import {CommitHashPlugin} from 'vite-plugin-commit-hash';
followed byplugins: [/*your other plugins*/, CommitHashPlugin({noPrefix:false,noVirtual:false})]
Usage
Import virtual:commit-hash
in your codebase;
import CommitHash from 'virtual:commit-hash';
console.log(CommitHash); // -> Current Hash - with '-dirty' at the end if there's uncommitted work.
Example Config
import { sveltekit } from '@sveltejs/kit/vite';
import { CommitHashPlugin } from 'vite-plugin-commit-hash';
import type { UserConfig } from 'vite';
/** @type {import('vite').UserConfig} */
const config: UserConfig = {
plugins: [sveltekit(), CommitHashPlugin({noPrefix:false,noVirtual:false})]
};
export default config;
Attribution
Developed by @ExponentialWorkload Licensed under the MIT License Slightly inspired by vite-plugin-git-revision