Skip to content

Exponential-Workload/vite-plugin-commit-hash

Repository files navigation

Vite-Plugin-Commit-Hash

Mini-Plugin used to provide commit hash information to the project.
This should work cross-framework just fine.

Installation

  1. pnpm i vite-plugin-commit-hash
  2. Load the plugin in your vite.config.js: import {CommitHashPlugin} from 'vite-plugin-commit-hash'; followed by plugins: [/*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

About

Allows you to get the Commit Hash in your Vite Codebase

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published