DISCLAIMER: As the original package from smnhgn/vite-plugin-package-version now supports ESM, we will be soon deprecating this package.
Load package version of your package.json into your vite environment.
Will inject import.meta.env.PACKAGE_VERSION
with the version specified in your package.json.
npm i @sws2apps/vite-plugin-package-version
// vite.config.js
import { defineConfig } from 'vite';
import { loadVersion } from '@sws2apps/vite-plugin-package-version';
export default defineConfig({
plugins: [loadVersion()],
});
This repo is taken from vite-plugin-package-version by Simon Haugen with only some minor edits. Thanks to Simon for the original repo.