0.0.3 • Published 11 months ago
@moreplease/rollup-plugin-build-info v0.0.3
rollup-plugin-build-info
Embed build metadata in your Rollup project (also compatible with Vite, Astro, etc).
Installation
npm add @moreplease/rollup-plugin-build-infoUsage
Add the plugin to your Rollup or Vite configuration file:
import buildInfo from "@moreplease/rollup-plugin-build-info";
export default {
...
plugins: [
buildInfo()
],
};At build time, we fetch the current time, git branch name and commit SHA. We get the git info from environment variables if possible (GITHUB_REF_NAME and GITHUB_SHA), otherwise we call git directly.
The build info looks like this:
type BuildInfo = {
branch: string;
commit: string;
timestamp: Date;
}Use it in your code by importing build-info:
import buildInfo from "build-info";
// Or if you prefer, import each field separately
import { branch, commit, timestamp } from "build-info";