vite-plugin-commit-hash
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i vite-plugin-commit-hash

Weekly Downloads

40

Version

1.0.8

License

MIT

Unpacked Size

10.7 kB

Total Files

11

Last publish

Collaborators

  • exponentialworkload