0.5.0 • Published 6 days ago

vite-plugin-build-metadata v0.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 days ago

💙 SPECIAL SPONSOR

Usage

Installation

Install the vite-plugin-build-metadata package as a development dependency using pnpm:

pnpm i vite-plugin-build-metadata -D

Configuration

Add the plugin to your vite.config.js file:

// vite.config.js
import VitePluginBuildMetadata from 'vite-plugin-build-metadata';

export default {
  plugins: [
    VitePluginBuildMetadata(),
  ],
};

Once the plugin is installed and configured, it will generate a file in the root build directory (default filename: meta.json) after each build. This file will contain the following information:

{
  "buildHash": "GENERATED_BUILD_HASH",
  "commitHash": "LAST_COMMIT_HASH",
  "date": "BUILD_DATE"
}

You can customize the filename by passing an options object to the VitePluginBuildMetadata constructor:

// vite.config.js
import VitePluginBuildMetadata from 'vite-plugin-build-metadata';

export default {
  plugins: [
    VitePluginBuildMetadata({ filename: 'custom-meta.json' }), // or without .json extension
  ],
};

Motivation

The vite-plugin-build-metadata plugin provides a way to determine the relevance of the deployed version of a frontend application. By including build and commit hashes, as well as the build date, in the generated metadata file, you can easily track and verify the version of your application in production.

This information can be useful in various scenarios, such as:

  • Ensuring that the correct version of the application is deployed in production environments.
  • Debugging issues by identifying the specific build and commit associated with a deployed version.
  • Comparing different builds to track changes and assess their impact.

Including build metadata in your frontend builds adds an extra layer of transparency and accountability to your development process.

License

MIT License © 2021 Daniil Chumachenko

0.5.0

6 days ago

0.3.0

8 months ago

0.2.0

12 months ago

0.3.2

8 months ago

0.4.0

8 months ago

0.3.1

8 months ago

0.1.1

1 year ago