npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

inject-git-info-webpack-plugin

v1.0.0

Published

InjectGitInfoWebpackPlugin是一个Webpack插件,用于将Git分支信息和项目版本号注入到构建的HTML文件中。这可以帮助您在部署的应用中快速识别当前使用的代码版本和分支。

Downloads

2

Readme

InjectGitInfoWebpackPlugin

InjectGitInfoWebpackPlugin是一个Webpack插件,用于将Git分支信息和项目版本号注入到构建的HTML文件中。这可以帮助您在部署的应用中快速识别当前使用的代码版本和分支。

功能

  • 自动获取当前Git分支名。
  • 将Git分支信息和项目版本号作为meta标签注入到HTML的head部分。
  • 提供选项以自定义插件行为,包括自定义命令以获取版本信息。

安装

使用npm安装:

npm install inject-git-info-webpack-plugin --save-dev

或者使用yarn:

yarn add inject-git-info-webpack-plugin --dev

使用方法

首先,将插件导入到您的Webpack配置文件中:

const InjectGitInfoWebpackPlugin = require('inject-git-info-webpack-plugin');

然后,将插件添加到您的Webpack插件数组中:

module.exports = {
  // ...其他配置
  plugins: [
    new InjectGitInfoWebpackPlugin(options),
    // ...其他插件
  ]
};

配置项

InjectGitInfoWebpackPlugin接受一个可选的配置对象,允许您自定义插件的行为:

  • name: 项目名称,默认使用process.env["npm_package_name"]。
  • version: 项目版本号,默认使用当前日期。
  • command: 自定义命令来获取版本信息,默认为"git rev-parse --abbrev-ref HEAD"获取Git分支名称。
  • branch: 直接指定分支名称,如果提供,将覆盖command的执行结果。

示例

将Git分支信息和自定义版本号注入到HTML中:

const InjectGitInfoWebpackPlugin = require('inject-git-info-webpack-plugin');

module.exports = {
  // ...其他配置
  plugins: [
    new InjectGitInfoWebpackPlugin({
      name: 'MyAwesomeProject',
      version: '1.2.3',
    }),
  ]
};