vite-plugin-version-mark

raw JSON →
0.2.2 verified Mon Apr 27 auth: no javascript

A Vite and Nuxt plugin (v0.2.2) that automatically injects version information from package.json, git commit SHA, or custom commands into your application via console logs, global variables, meta tags, and static output files. It supports multi-command execution with custom format templates, aliases, timeouts, and fallbacks. Particularly useful for tracking deployed builds and debugging in production. Ships TypeScript types. Requires Vite or Nuxt 3.3+. Released under MIT.

error Failed to load url /@vite-plugin-version-mark/nuxt (resolved id: /@vite-plugin-version-mark/nuxt)
cause Importing nuxt module from the main package path instead of subpath.
fix
Use import { nuxtModule } from 'vite-plugin-version-mark/nuxt' or load as module in nuxt.config.
error Module '"vite-plugin-version-mark"' has no default export
cause Attempting to import the plugin as default export.
fix
Use named import: import { vitePluginVersionMark } from 'vite-plugin-version-mark'.
error TypeError: Cannot read properties of undefined (reading 'version')
cause The plugin cannot read package.json if the command is not run from the project root.
fix
Ensure the Vite/Nuxt config file is at the project root, or explicitly set 'name' and 'version' in plugin options.
deprecated The 'ifGitSHA' option was deprecated in v0.0.12; use 'ifShortSHA' instead.
fix Replace 'ifGitSHA: true' with 'ifShortSHA: true' in plugin config.
breaking In v0.2.0, the 'command' option was replaced by multi-command support using an object or array format.
fix Migrate single 'command' string to new format: e.g., { commands: [{ command: 'git rev-parse --short HEAD', alias: 'sha' }] }.
gotcha The global variable is injected via a script tag in the HTML <head> (since v0.1.3).
fix Access global variable like `__APP_VERSION__` after DOMContentLoaded if needed.
gotcha Nuxt module requires @nuxt/kit and @nuxt/schema >3.3.0 as peer dependencies.
fix Ensure Nuxt 3.3+ is installed in your project.
deprecated The 'outputFile' option was added in v0.1.1; older versions have no file output support.
fix Upgrade to v0.1.1+ or use a custom plugin to write version file.
npm install vite-plugin-version-mark
yarn add vite-plugin-version-mark
pnpm add vite-plugin-version-mark

Minimal setup for Vite: enables short git SHA, meta tags, console log, and global variable injection.

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

export default defineConfig({
  plugins: [
    vitePluginVersionMark({
      ifShortSHA: true,
      ifMeta: true,
      ifLog: true,
      ifGlobal: true,
    }),
  ],
});