/vite-plugin-version-mark

Automatically use `package version` / `git commit` / `custom` to be inserted into your project as a unique identifier for the project version.

Primary LanguageTypeScript

vite-plugin-version-mark

Automatically insert the version or git_commit_sha in your project

Downloads Version License

Demo

demo screen shot

Install

yarn add -D vite-plugin-version-mark
# OR npm install -D vite-plugin-version-mark

Usage

// vite.config.ts
import {defineConfig} from 'vite'
import {vitePluginVersionMark} from 'vite-plugin-version-mark'

export default defineConfig({
  plugins: [
    vitePluginVersionMark({
      // name: 'test-app',
      // version: '0.0.1',
      ifGitSHA: true,
      ifShortSHA: true,
      ifMeta: true,
      ifLog: true,
      ifGlobal: true,
    })
  ],
})

Config

vite-plugin-version-mark can be print application version in the Console or add <meta> in HTML element.

  • name - application name (name in package.json by default)
  • version - application version (version in package.json by default)
  • ifGitSHA - use git commit SHA as the version (false by default)
  • ifShortSHA - use git commit short SHA (true by default)
  • ifMeta - add <meta name="application-name" content="{APPNAME_VERSION}: {version}"> in the <head> (true by default)
  • ifLog - print info in the Console (true by default)
  • ifGlobal - set a variable named `__${APPNAME}_VERSION__` in the window. (true by default)

Then you can use vite-plugin-version-mark ! 🎉