{"id":13775059,"url":"https://github.com/djhouseknecht/rollup-plugin-version-injector","last_synced_at":"2026-01-12T02:37:16.891Z","repository":{"id":34981058,"uuid":"192985276","full_name":"djhouseknecht/rollup-plugin-version-injector","owner":"djhouseknecht","description":"rollup.js plugin to auto inject the current version into the source code ","archived":false,"fork":false,"pushed_at":"2023-10-22T18:51:06.000Z","size":594,"stargazers_count":12,"open_issues_count":22,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-15T08:07:48.163Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/djhouseknecht.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-06-20T20:45:19.000Z","updated_at":"2023-07-11T17:56:33.000Z","dependencies_parsed_at":"2024-01-13T12:52:44.501Z","dependency_job_id":"4b9302e1-238c-45b6-8956-c41407255759","html_url":"https://github.com/djhouseknecht/rollup-plugin-version-injector","commit_stats":{"total_commits":25,"total_committers":4,"mean_commits":6.25,"dds":"0.19999999999999996","last_synced_commit":"a5efe3b6015236662930f1442096e329372014cc"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djhouseknecht%2Frollup-plugin-version-injector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djhouseknecht%2Frollup-plugin-version-injector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djhouseknecht%2Frollup-plugin-version-injector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djhouseknecht%2Frollup-plugin-version-injector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/djhouseknecht","download_url":"https://codeload.github.com/djhouseknecht/rollup-plugin-version-injector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253533716,"owners_count":21923503,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-03T17:01:33.334Z","updated_at":"2026-01-12T02:37:16.843Z","avatar_url":"https://github.com/djhouseknecht.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Output"],"readme":"[![Build Status](https://travis-ci.org/djhouseknecht/rollup-plugin-version-injector.svg?branch=master)](https://travis-ci.org/djhouseknecht/rollup-plugin-version-injector)  [![codecov](https://codecov.io/gh/djhouseknecht/rollup-plugin-version-injector/branch/master/graph/badge.svg)](https://codecov.io/gh/djhouseknecht/rollup-plugin-version-injector)  [![npm version](https://badge.fury.io/js/rollup-plugin-version-injector.svg)](https://badge.fury.io/js/rollup-plugin-version-injector)  [![dependabot-status](https://flat.badgen.net/dependabot/djhouseknecht/rollup-plugin-version-injector/?icon=dependabot)](https://dependabot.com)  [![semantic-release](https://img.shields.io/badge/20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) \n\n# rollup-plugin-version-injector\nA simple [rollup.js] plugin to inject your application's version number and/or today's date into your built `js`, `html`, and `css` files!\n\n## Getting started\n\nInstall from npm\n``` bash\nnpm i --save-dev rollup-plugin-version-injector\n```\n\nAdd it to your `rollup.config.js` build configuration. \n\n``` js \nimport versionInjector from 'rollup-plugin-version-injector';\n// or\nconst versionInjector = require('rollup-plugin-version-injector');\n\nexport default {\n  // other configuration\n  plugins: [\n    versionInjector()\n    // any other plugins\n  ]\n};\n```\n\nThen you can add tags to your source code and it will inject the version where you specified. Example: \n\n**src/app.js** (example file)\n```js \nexport class MyApp {\n  getVersion() { \n    return '[VI]{version} - {date}[/VI]';\n  }\n  // other code\n}\n```\n\n**version-injector** (**VI**) will replace that code in your built source to return the following: \n\n**build/built-app.js** (example build file)\n```js \nexport class MyApp {\n  getVersion() { \n    return '1.2.1 - June 9, 2007 17:46:12';\n  }\n  // other code\n}\n```\nVI will also inject the version into your files as a comment. Example: \n\n**build/index.html** (example file)\n``` html\n\u003c!-- Version: 1.2.1 - June 9, 2007 17:46:12 --\u003e\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  ...\n\u003c/html\u003e\n```\n## Basic Usage\n\nVI has two uses -- it will Inject the version number and/or today's date into your generated files in:\n1. [Defined tags in your source code.](####injected-in-the-source-code)\n2. [A comment at the top of the file.](####as-a-comment)\n\nVI will replace `'{version}'` with the version found in your `package.json` and `'{date}'` with today's date in the format specified in the [configuration].\n\n\u003e VI supports injecting the version into all `js`, `html`, and `css` files output by rollup. \n\n## Injected in the source code\nVI will only look between the configured `tagId`s. For example, the default `tagId` is `VI` so VI is looking for: \n```js \n// string in your javascript file\nconst VERSION = '[VI]Version: {version} - built on {date}[/VI]';\n``` \nVI will only replace the `'{version}'` and `'{date}'` found within those `tagId`s. \n```js \n// output after VI has run\nconst VERSION = 'Version: 1.2.1 - built on June 9, 2007 17:46:12';\n``` \n\nYou can change the date format, tagId, and which files to look in using the [configuration] object passed into the `versionInjector()` function. \n\n## As a comment\nIt will replace the `'{version}'` and `'{date}'` found in the configured `tag`. For example, the default configured `tag` is:\n```js\ntag: 'Version: {version} - {date}'\n```\n\nYou can change the date format, tag, and which files to inject the comment into using the [configuration] object passed into the `versionInjector()` function. \n\n\n## Configuration\n\nAnything not specified/overwritten in your `versionInjector()` configuration will use the default configuration. \n\n**default config**\n```js \n{\n  injectInComments: {\n    fileRegexp: /\\.(js|html|css)$/,\n    tag: 'Version: {version} - {date}',\n    dateFormat: 'mmmm d, yyyy HH:MM:ss'\n  },\n  injectInTags: {\n    fileRegexp: /\\.(js|html|css)$/,\n    tagId: 'VI',\n    dateFormat: 'mmmm d, yyyy HH:MM:ss'\n  },\n  packageJson: './package.json',\n  logLevel: 'info',\n  logger: console,\n  exclude: []\n};\n```\n\nAll available date formats can be found at [dateformat]. \n\n#### injectInTags\nThe following properties are available:\n```typescript \nversionInjector({\n  injectInTags: false /* or */ {\n    // Regexp for files to match against\n    fileRegexp: Regex \n    // string of the tagId to look for\n    // Ex: 'ACK' =\u003e VI will look for '[ACK]...[/ACK]'\n    tagId: string \n    // string of valid dateformat \n    dateFormat: string \n  }\n})\n```\n\u003e **Note:** The `tagId` will be wrapped in opening and closing brackets.  Example: `[tagId][/tagId]`\n\nAll available date formats can be found at [dateformat]. \n\n#### injectInComments\nThe following properties are available:\n```typescript \nversionInjector({\n  injectInComments: false /* or */ {\n    // Regexp for files to match against\n    fileRegexp: Regex \n    // string of tag to be injected\n    tagId: string \n    // string of valid dateformat \n    dateFormat: string \n  }\n})\n```\n\n#### packageJson\nThis is the relative path to your `package.json` file from your rollup config file. Default is `'./package.json'`. \n\n#### logLevel\nThis is the log levels for verion-injector. Default value is `'info'`. Available values are:\n``` \n'debug', 'info', 'warn', 'error'\n```\n\n#### logger\nDefault is the `console`, but can be any logger you prefer that matches the [`ILogger`](src/types/interfaces.ts#ILogger) interface. \n\n#### excludes \nThis is an array of specific files you want to exclude from any processing. This must be the full file name without the path. \n\n## Credits\nThis is essentially a less fancy port of the [webpack-auto-inject-version].\n\n[rollup.js]: https://rollupjs.org/guide/en\n[dateformat]: https://www.npmjs.com/package/dateformat\n[dateformat's]: https://www.npmjs.com/package/dateformat\n[webpack-auto-inject-version]: https://github.com/radswiat/webpack-auto-inject-version\n[configuration]: ##configuration","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjhouseknecht%2Frollup-plugin-version-injector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjhouseknecht%2Frollup-plugin-version-injector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjhouseknecht%2Frollup-plugin-version-injector/lists"}