How to use the plug-in git-revision-webpack-plugin in nuxt and how to configure it?

nuxt  git-revision-webpack-plugin
Nov.14,2021

git-revision-webpack-plugin is a plug-in based on webpack. Its main function is to obtain the current git version number and branch information.
you need to install it in the project before using it: npm install-- save-dev git-revision-webpack-plugin
and then configure it in the configuration file nuxt.config.js of the nuxt project

.
 const GitRevisionPlugin = require('git-revision-webpack-plugin');
 const gitRevisionPlugin = new GitRevisionPlugin();
 const webpack = require('webpack');
 build: {
    plugins: [
      new webpack.DefinePlugin({
        'process.VERSION': JSON.stringify(gitRevisionPlugin.version()),
        'process.COMMITHASH': JSON.stringify(gitRevisionPlugin.commithash()),
        'process.BRANCH': JSON.stringify(gitRevisionPlugin.branch()),
      }),
    ],
  },
Menu