Socket
Socket
Sign inDemoInstall

git-revision-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git-revision-webpack-plugin

[![npm version](https://badge.fury.io/js/git-revision-webpack-plugin.svg)](https://badge.fury.io/js/git-revision-webpack-plugin) [![downloads](https://img.shields.io/npm/dm/git-revision-webpack-plugin.svg?style=flat-square)](https://www.npmjs.com/package/


Version published
Weekly downloads
134K
increased by2.49%
Maintainers
1
Weekly downloads
 
Created

What is git-revision-webpack-plugin?

The git-revision-webpack-plugin is a Webpack plugin that allows you to embed Git revision information into your build. This can be useful for versioning, debugging, and tracking the state of your codebase at the time of the build.

What are git-revision-webpack-plugin's main functionalities?

Embed Git Revision Information

This feature allows you to embed the current Git revision information into your Webpack build. The code sample shows how to include the GitRevisionPlugin in your Webpack configuration.

const GitRevisionPlugin = require('git-revision-webpack-plugin');
const gitRevisionPlugin = new GitRevisionPlugin();

module.exports = {
  plugins: [
    gitRevisionPlugin
  ]
};

Access Git Information in Code

This feature allows you to access Git information such as the version, commit hash, and branch name directly in your code. The code sample demonstrates how to log this information to the console.

const GitRevisionPlugin = require('git-revision-webpack-plugin');
const gitRevisionPlugin = new GitRevisionPlugin();

console.log('Version:', gitRevisionPlugin.version());
console.log('Commit Hash:', gitRevisionPlugin.commithash());
console.log('Branch:', gitRevisionPlugin.branch());

Define Global Constants

This feature allows you to define global constants in your Webpack configuration that hold Git information. The code sample shows how to use the DefinePlugin to create global constants for the version, commit hash, and branch name.

const GitRevisionPlugin = require('git-revision-webpack-plugin');
const gitRevisionPlugin = new GitRevisionPlugin();

module.exports = {
  plugins: [
    new webpack.DefinePlugin({
      'VERSION': JSON.stringify(gitRevisionPlugin.version()),
      'COMMITHASH': JSON.stringify(gitRevisionPlugin.commithash()),
      'BRANCH': JSON.stringify(gitRevisionPlugin.branch())
    })
  ]
};

Other packages similar to git-revision-webpack-plugin

FAQs

Package last updated on 05 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc