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

vite-plugin-git-commit-hash

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-git-commit-hash

a vite plugin that gets the latest git commit hash

1.0.7
latest
Source
npm
Version published
Weekly downloads
899
-11.43%
Maintainers
1
Weekly downloads
 
Created
Source

vite-plugin-git-commit-hash

insert a variable GIT_COMMIT_HASH that can be printed out in your console

This plugin defines a global variable GIT_COMMIT_HASH in your javascript/typescript. It is compatible with both commonjs and esm, with typescript declaration supplied.

Install

pnpm add -D vite-plugin-git-commit-hash

Usage

1. vite config

import { defineConfig } from "vite";
import { gitCommitHashPlugin } from "vite-plugin-git-commit-hash";

export default defineConfig((config) => {
  return {
    plugins: [
      /**
       * ..your plugins
       */
      gitCommitHashPlugin(),
    ]
  };
});

2. in your typescript/javascript

/**
 * use the variable GIT_COMMIT_HASH
 *
 * GIT_COMMIT_HASH is defined by vite-plugin-git-commit-hash
 */
console.info(GIT_COMMIT_HASH);

3. typescript declaration (optional)

/**
 * in any of your typescript declaration files, for example global.d.ts
 * you will get typescript code autocompletion in your editor
 */
declare const GIT_COMMIT_HASH: string;

Keywords

vite

FAQs

Package last updated on 18 Feb 2024

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