🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

vite-plugin-commit-hash

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-commit-hash

Exposes the current commit hash to the codebase

1.0.8
latest
Source
npm
Version published
Weekly downloads
42
-23.64%
Maintainers
1
Weekly downloads
 
Created
Source

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 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

Keywords

vite-plugin

FAQs

Package last updated on 03 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts