Gathering detailed insights and metrics for @rednil/rollup-plugin-version-injector
Gathering detailed insights and metrics for @rednil/rollup-plugin-version-injector
Gathering detailed insights and metrics for @rednil/rollup-plugin-version-injector
Gathering detailed insights and metrics for @rednil/rollup-plugin-version-injector
rollup.js plugin to auto inject the current version into the source code
npm install @rednil/rollup-plugin-version-injector
Typescript
Module System
Node Version
NPM Version
TypeScript (98.2%)
JavaScript (1.8%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
14 Commits
6 Branches
1 Contributors
Updated on Dec 04, 2020
Latest Version
1.0.0
Package Id
@rednil/rollup-plugin-version-injector@1.0.0
Unpacked Size
65.54 kB
Size
12.58 kB
File Count
25
NPM Version
6.14.9
Node Version
14.15.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A simple rollup.js plugin to inject your application's version number and/or today's date into your built js
, html
, and css
files!
Install from npm
1npm i --save-dev rollup-plugin-version-injector
Add it to your rollup.config.js
build configuration.
1import versionInjector from 'rollup-plugin-version-injector'; 2// or 3const versionInjector = require('rollup-plugin-version-injector'); 4 5export default { 6 // other configuration 7 plugins: [ 8 versionInjector() 9 // any other plugins 10 ] 11};
Then you can add tags to your source code and it will inject the version where you specified. Example:
src/app.js (example file)
1export class MyApp { 2 getVersion() { 3 return '[VI]{version} - {date}[/VI]'; 4 } 5 // other code 6}
version-injector (VI) will replace that code in your built source to return the following:
build/built-app.js (example build file)
1export class MyApp { 2 getVersion() { 3 return '1.2.1 - June 9, 2007 17:46:12'; 4 } 5 // other code 6}
VI will also inject the version into your files as a comment. Example:
build/index.html (example file)
1<!-- Version: 1.2.1 - June 9, 2007 17:46:12 --> 2<!DOCTYPE html> 3<html lang="en"> 4 ... 5</html>
VI has two uses -- it will Inject the version number and/or today's date into your generated files in:
VI will replace '{version}'
with the version found in your package.json
and '{date}'
with today's date in the format specified in the configuration.
VI supports injecting the version into all
js
,html
, andcss
files output by rollup.
VI will only look between the configured tagId
s. For example, the default tagId
is VI
so VI is looking for:
1// string in your javascript file 2const VERSION = '[VI]Version: {version} - built on {date}[/VI]';
VI will only replace the '{version}'
and '{date}'
found within those tagId
s.
1// output after VI has run 2const VERSION = 'Version: 1.2.1 - built on June 9, 2007 17:46:12';
You can change the date format, tagId, and which files to look in using the configuration object passed into the versionInjector()
function.
It will replace the '{version}'
and '{date}'
found in the configured tag
. For example, the default configured tag
is:
1tag: 'Version: {version} - {date}'
You can change the date format, tag, and which files to inject the comment into using the configuration object passed into the versionInjector()
function.
Anything not specified/overwritten in your versionInjector()
configuration will use the default configuration.
default config
1{ 2 injectInComments: { 3 fileRegexp: /\.(js|html|css)$/, 4 tag: 'Version: {version} - {date}', 5 dateFormat: 'mmmm d, yyyy HH:MM:ss' 6 }, 7 injectInTags: { 8 fileRegexp: /\.(js|html|css)$/, 9 tagId: 'VI', 10 dateFormat: 'mmmm d, yyyy HH:MM:ss' 11 }, 12 packageJson: './package.json', 13 logLevel: 'info', 14 logger: console, 15 exclude: [] 16};
All available date formats can be found at dateformat.
The following properties are available:
1versionInjector({ 2 injectInTags: false /* or */ { 3 // Regexp for files to match against 4 fileRegexp: Regex 5 // string of the tagId to look for 6 // Ex: 'ACK' => VI will look for '[ACK]...[/ACK]' 7 tagId: string 8 // string of valid dateformat 9 dateFormat: string 10 } 11})
Note: The
tagId
will be wrapped in opening and closing brackets. Example:[tagId][/tagId]
All available date formats can be found at dateformat.
The following properties are available:
1versionInjector({ 2 injectInComments: false /* or */ { 3 // Regexp for files to match against 4 fileRegexp: Regex 5 // string of tag to be injected 6 tagId: string 7 // string of valid dateformat 8 dateFormat: string 9 } 10})
This is the relative path to your package.json
file from your rollup config file. Default is './package.json'
.
This is the log levels for verion-injector. Default value is 'info'
. Available values are:
'debug', 'info', 'warn', 'error'
Default is the console
, but can be any logger you prefer that matches the ILogger
interface.
This is an array of specific files you want to exclude from any processing. This must be the full file name without the path.
This is essentially a less fancy port of the webpack-auto-inject-version.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/14 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
58 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More