Vite plugin that injects the version from package.json into the Vite environment as import.meta.env.PACKAGE_VERSION. Version 1.1.0 is the current stable release; it requires Vite >=2.0.0-beta.69. The plugin is lightweight and focused solely on exposing the package version. Unlike rollup plugins or manual env variable injection, it provides a simple, zero-config approach for Vite projects. No breaking changes reported; TypeScript types are included.
npm install vite-plugin-package-versionVerified import paths — ran on the pinned version, not inferred.
Shows installation, plugin setup in vite.config.js, and usage of the injected PACKAGE_VERSION env variable.
Upgrade Vite to version 2.0.0-beta.69 or later.
Use dynamic import or build-time replacement if needed outside Vite environment.
Parse with Number() or use string methods as appropriate.
Ensure package.json is in the root directory of the Vite project.
Run 'npm install vite-plugin-package-version' and ensure import uses default style.
Add version() to plugins array in vite.config.js.
Move access inside a function or component that runs after Vite resolves.
Use import syntax or set type: 'module' in package.json.