# vite-plugin-commit-hash

> Exposes the current commit hash to the codebase

Latest version **1.0.8** (published 2023-12-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install vite-plugin-commit-hash
pnpm add vite-plugin-commit-hash
yarn add vite-plugin-commit-hash
bun add vite-plugin-commit-hash
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2023-12-03 |
| First published | 2023-02-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ExponentialWorkload |
| Maintainers | exponentialworkload |
| Keywords | vite-plugin |

## Links

- npm: https://www.npmjs.com/package/vite-plugin-commit-hash
- Repository: https://github.com/Exponential-Workload/vite-plugin-commit-hash
- Issues: https://github.com/Exponential-Workload/vite-plugin-commit-hash/issues
- npm.io page: https://npm.io/package/vite-plugin-commit-hash

## Dependencies (2)

- [magic-string](https://npm.io/package/magic-string.md) ^0.30.5
- [@rollup/pluginutils](https://npm.io/package/@rollup/pluginutils.md) ^5.1.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.0.8 (latest) — 2023-12-03
- 1.0.7 — 2023-12-03
- 1.0.6 — 2023-11-30
- 1.0.5 — 2023-03-09
- 1.0.4 — 2023-03-09
- 1.0.3 — 2023-03-09
- 1.0.2 — 2023-02-02
- 1.0.1 — 2023-02-02
- 1.0.0 — 2023-02-02

## README

# Vite-Plugin-Commit-Hash

Mini-Plugin used to provide commit hash information to the project.<br/>
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;
```js
import CommitHash from 'virtual:commit-hash';
console.log(CommitHash); // -> Current Hash - with '-dirty' at the end if there's uncommitted work.
```

### Example Config

```js
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](https://github.com/Exponential-Workload)<br/>
Licensed under the [MIT License](./LICENSE)<br/>
Slightly inspired by [vite-plugin-git-revision](https://github.com/qduld/vite-plugin-git-revision)

---
_Source: https://npm.io/package/vite-plugin-commit-hash · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
