{"id":13606548,"url":"https://github.com/yjl9903/unplugin-info","last_synced_at":"2026-04-20T22:01:41.690Z","repository":{"id":39414776,"uuid":"506914295","full_name":"yjl9903/unplugin-info","owner":"yjl9903","description":"Export build information as a virutal module","archived":false,"fork":false,"pushed_at":"2026-04-16T19:11:25.000Z","size":5321,"stargazers_count":108,"open_issues_count":5,"forks_count":8,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-16T21:16:50.831Z","etag":null,"topics":["astro","ci","git","plugin","unplugin","vite","vite-plugin","webpack"],"latest_commit_sha":null,"homepage":"https://yjl9903.github.io/unplugin-info/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yjl9903.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["yjl9903"]}},"created_at":"2022-06-24T07:12:47.000Z","updated_at":"2026-04-16T19:10:45.000Z","dependencies_parsed_at":"2023-09-21T21:57:04.644Z","dependency_job_id":"a6b8901e-b387-4a00-ad7e-d8ef0d193648","html_url":"https://github.com/yjl9903/unplugin-info","commit_stats":{"total_commits":193,"total_committers":2,"mean_commits":96.5,"dds":"0.14507772020725385","last_synced_commit":"de451b1b67819c4ed8e03cd6607604cb24f05c05"},"previous_names":["yjl9903/vite-plugin-info"],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/yjl9903/unplugin-info","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjl9903%2Funplugin-info","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjl9903%2Funplugin-info/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjl9903%2Funplugin-info/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjl9903%2Funplugin-info/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yjl9903","download_url":"https://codeload.github.com/yjl9903/unplugin-info/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjl9903%2Funplugin-info/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32011019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astro","ci","git","plugin","unplugin","vite","vite-plugin","webpack"],"created_at":"2024-08-01T19:01:10.134Z","updated_at":"2026-04-20T22:01:41.678Z","avatar_url":"https://github.com/yjl9903.png","language":"TypeScript","readme":"# unplugin-info\n\n[![Demo](https://img.shields.io/badge/unplugin--info-demo-00CCAA)](https://yjl9903.github.io/unplugin-info/)\n[![version](https://img.shields.io/npm/v/unplugin-info?label=unplugin-info)](https://www.npmjs.com/package/unplugin-info)\n[![install size](https://packagephobia.com/badge?p=unplugin-info)](https://packagephobia.com/result?p=unplugin-info)\n[![GitHub License](https://img.shields.io/github/license/yjl9903/unplugin-info)](https://github.com/yjl9903/unplugin-info/blob/main/LICENSE)\n[![CI](https://github.com/yjl9903/unplugin-info/actions/workflows/ci.yml/badge.svg)](https://github.com/yjl9903/unplugin-info/actions/workflows/ci.yml)\n\nExport build information as virutal module.\n\nThis plugin helps you add **build timestamp** / **commit SHA** / **CI environment** / `package.json` / ... to your application. So you can easily check whether the production version meets your expectations, or config your application.\n\n\u003e **Migration from v0 to v1**\n\u003e\n\u003e + Move git related information from `~build/info` to `~build/git`\n\u003e + Move CI related information from `~build/info` to `~build/ci`\n\u003e + Remove `commitsSinceLastTag` from `~build/git`\n\n## Installation\n\n```bash\nnpm i -D unplugin-info\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eVite\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// vite.config.ts\n\nimport Info from 'unplugin-info/vite';\n\nexport default defineConfig({\n  plugins: [\n    Info()\n  ]\n});\n```\n\nFull example is located at [examples/vite](https://github.com/yjl9903/unplugin-info/blob/main/examples/vite).\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eRollup\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// rollup.config.js\n\nimport Info from 'unplugin-info/rollup';\n\nexport default {\n  plugins: [\n    Info()\n  ]\n};\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eRspack\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// rspack.config.js\n\nmodule.exports = {\n  /* ... */\n  plugins: [\n    require('unplugin-info/rspack')()\n  ]\n};\n```\n\nFull example is located at [examples/rspack](https://github.com/yjl9903/unplugin-info/blob/main/examples/rspack).\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eWebpack\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// webpack.config.js\n\nmodule.exports = {\n  /* ... */\n  plugins: [\n    require('unplugin-info/webpack')()\n  ]\n};\n```\n\nFull example is located at [examples/webpack](https://github.com/yjl9903/unplugin-info/blob/main/examples/webpack).\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eNuxt\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// nuxt.config.ts\n\nexport default defineNuxtConfig({\n  modules: ['unplugin-info/nuxt'],\n  info: {\n    // Your unplugin-info options ...\n  }\n});\n```\n\nFull example is located at [examples/nuxt](https://github.com/yjl9903/unplugin-info/blob/main/examples/nuxt).\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eVue CLI\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// vue.config.js\n\nmodule.exports = {\n  configureWebpack: {\n    plugins: [\n      require('unplugin-info/webpack')()\n    ]\n  }\n};\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eQuasar\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// quasar.conf.js [Vite]\nmodule.exports = {\n  vitePlugins: [\n    [\n      'unplugin-info/vite',\n      {\n        /* options */\n      }\n    ]\n  ]\n};\n```\n\n```ts\n// quasar.conf.js [Webpack]\nconst Info = require('unplugin-info/webpack');\n\nmodule.exports = {\n  build: {\n    chainWebpack(chain) {\n      chain.plugin('unplugin-info').use(\n        Info()\n      );\n    }\n  }\n};\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eesbuild\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// esbuild.config.js\nimport { build } from 'esbuild';\n\nbuild({\n  /* ... */\n  plugins: [\n    require('unplugin-info/esbuild')({\n      /* options */\n    }),\n  ],\n});\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eAstro\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// astro.config.mjs\n\nimport Info from 'unplugin-info/astro';\n\nexport default defineConfig({\n  integrations: [\n    Info()\n  ],\n});\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n### TypeScript\n\nTo make the TypeScript work, you can add `unplugin-info/client` to your corresponding `tsconfig.json`.\n\n```json5\n{\n  \"compilerOptions\": {\n    // ...\n    \"types\": [\n      \"unplugin-info/client\"\n    ],\n  },\n  // ...\n}\n```\n\nOr you can add TypeScript [triple-slash directives](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html) to your `.d.ts` (i.e. for projects initialized by Vite, it may be `src/env.d.ts`).\n\n```ts\n// Your .d.ts file\n\n/// \u003creference types=\"unplugin-info/client\" /\u003e\n```\n\nOr if you did some advanced modification (see below), you can just copy and paste [client.d.ts](https://github.com/yjl9903/unplugin-info/blob/main/client.d.ts) to your project, and then do anything you want.\n\n## Usage\n\n`unplugin-info` creates several virtual modules, `~build/time`, `~build/git`, `~build/ci`, `~build/console`, `~build/meta`, `~build/env`, and `~build/package`.\n\nYou can just import these modules as usual, and do anything with them. Common use cases may be like:\n\n```ts\n// main.ts\n\nimport now from '~build/time'\nimport { sha } from '~build/git'\n\n// console log the build info\nconsole.log(`Build ${sha} at ${now}`)\n```\n\n```tsx\n// App.tsx\n\nimport now from '~build/time'\n\n// Render it in your app\nfunction App() {\n  return \u003cspan\u003e{now.toLocaleString()}\u003c/span\u003e\n}\n```\n\n### ~build/time\n\nIt exports the timestamp when the vite started.\n\n```ts\nimport now from '~build/time'\n\nconsole.log(now)\n// There will be a log like \"Fri Jun 24 2022 16:30:30 GMT+0800 (中国标准时间)\"\n```\n\n### ~build/git\n\nIt exports the infomation about the current git repo, which is powered by [simple-git](https://www.npmjs.com/package/simple-git).\n\n```ts\nimport {\n  github,\n  sha,\n  abbreviatedSha,\n  tag,\n  lastTag,\n  committer,\n  committerEmail,\n  committerDate,\n  author,\n  authorEmail,\n  authorDate,\n  commitMessage\n} from '~build/git';\n\n// ...\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e From `unplugin-info@0.6.0`, the original virtual module called `~build/info` will be renamed to `~build/git`, and the CI/CD related information will be moved to another virtual module called `~build/ci`.\n\nYou can even **custom or override the exported git information**.\n\nAll the functions will be executed during the generation of `~build/git`, and the return result with its corresponding field name will be merged into `~build/git`. The following example adds another `isClean` field to `~build/git`.\n\n```ts\n// vite.config.ts\n\nimport Info from 'unplugin-info/vite';\n\nexport default defineConfig({\n  plugins: [\n    Info({\n      git: {\n        // Gets whether this represents a clean working branch.\n        isClean: async (git) =\u003e {\n          const status = await git.status()\n          return status.isClean()\n        }\n      }\n    })\n  ]\n});\n```\n\nFull example is located at [examples/vite](https://github.com/yjl9903/unplugin-info/blob/main/examples/vite/vite.config.ts).\n\n### ~build/ci\n\nIt exports the current CI/CD environment information, which is powered by [ci-info](https://github.com/watson/ci-info).\n\n```ts\nimport { isCI, isPR, name } from '~build/ci'\n```\n\n### ~build/console\n\nIt will print some helpful logs in your browser.\n\n```ts\nimport '~build/console';\n```\n\n### ~build/meta\n\nIt exports some meta data from the options of the plugin.\n\n```ts\n// vite.config.ts\nexport default defineConfig({\n  plugins: [\n    BuildInfo({\n      meta: { message: 'This is set from vite.config.ts' }\n    })\n  ]\n})\n```\n\nYou can also generate meta data lazily.\n\n```ts\n// vite.config.ts\nexport default defineConfig({\n  plugins: [\n    BuildInfo({\n      meta: async () =\u003e ({ message: 'This is set from vite.config.ts' })\n    })\n  ]\n})\n```\n\nThen you can import them in your app.\n\n```ts\nimport { message } from '~build/meta'\n\nconsole.log(message)\n// This is set from vite.config.ts\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e Meta data will be serialized to JSON format, so you should gen it in you `vite.config.ts` and pass the result object.\n\nTo get TypeScript support, you can add type declaration in your `env.d.ts` (It is include in the [official Vite project template](https://vitejs.dev/guide/#scaffolding-your-first-vite-project)).\n\n```ts\ndeclare module '~build/meta' {\n  export const message: string;\n}\n```\n\nFull example is located at [examples/vite](https://github.com/yjl9903/unplugin-info/blob/main/examples/vite/vite.config.ts).\n\n### ~build/env\n\n\u003e [!NOTE]\n\u003e\n\u003e Now it only suports for Vite.\n\nIt exports some environment data from the options of the plugin.\n\n```ts\n// vite.config.ts\nexport default defineConfig({\n  plugins: [\n    BuildInfo({\n      env: { BUILD_MESSAGE: 'This is a default value set from vite.config.ts' }\n    })\n  ]\n})\n```\n\nCompared with `~build/meta`, `~build/env` is targeted at accessing environment variables for the SSR runtime (like Nuxt, Remix, Astro, and so on).\n\nThen you can import them in your Vite app.\n\n```ts\nimport { BUILD_MESSAGE } from '~build/env'\n\nconsole.log(BUILD_MESSAGE)\n```\n\nIn the client-side, this will always output `This is a default value set from vite.config.ts`.\n\nBut in the server-side, the output log is determined by the corresponding environment variable `process.env.BUILD_MESSAGE`.\n\nTo get TypeScript support, you can add type declaration in your `env.d.ts` (It is include in the [official Vite project template](https://vitejs.dev/guide/#scaffolding-your-first-vite-project)).\n\n```ts\ndeclare module '~build/env' {\n  export const BUILD_MESSAGE: string;\n}\n```\n\n### ~build/package\n\nIt exports the information of the current `package.json`.\n\n```ts\nimport { name, version } from '~build/package';\n```\n\nYou can also **control which fields should be exported**. By default, we only export fields name, version, description, keywords, license, author from your package.json.\n\n```ts\n// vite.config.ts\n\nimport Info from 'unplugin-info/vite';\n\nexport default defineConfig({\n  plugins: [\n    Info({\n      package: {\n        dependencies: true\n      }\n    })\n  ]\n});\n```\n\nFull example is located at [examples/vite](https://github.com/yjl9903/unplugin-info/blob/main/examples/vite/vite.config.ts).\n\n## Relationship with [vite-plugin-info](https://www.npmjs.com/package/vite-plugin-info)\n\nThis pacakge was initially called [vite-plugin-info](https://www.npmjs.com/package/vite-plugin-info). It has been refactored using [unplugin](https://www.npmjs.com/package/unplugin) to support additional tools, including Webpack and so on.\n\nWe recommend migrating from [vite-plugin-info](https://www.npmjs.com/package/vite-plugin-info) to [unplugin-info](https://www.npmjs.com/package/unplugin-info), as [unplugin-info](https://www.npmjs.com/package/unplugin-info) will continue to be maintained and new features will be added.\n\nHowever, you can still use [vite-plugin-info](https://www.npmjs.com/package/vite-plugin-info), as it works fine. Thanks to Vite's compatibility, and the source code of [vite-plugin-info](https://www.npmjs.com/package/vite-plugin-info) can be founded [here](https://github.com/yjl9903/unplugin-info/tree/vite-plugin-info).\n\n## License\n\nMIT License © 2023 [XLor](https://github.com/yjl9903)\n","funding_links":["https://github.com/sponsors/yjl9903"],"categories":["TypeScript","astro","Plugins"],"sub_categories":["Framework-agnostic Plugins"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyjl9903%2Funplugin-info","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyjl9903%2Funplugin-info","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyjl9903%2Funplugin-info/lists"}