Trying to add GitRevisionPlugin to CLI 3

There’s a webpack plugin that lets you access things like git hashes in your JS code.

In the existing build of our app that has a large and complex webpack config, the relevant code is here:

and here:

I’ve looked at the docs, I understand how to add plugins, and I understand how to DefinePlugins. What I can’t get is how to reference the plugin, as it’s done above.

I’m sure I’m just missing something obvious, but it’s not working for me.


I did it this way

// vue.config.js
const GitRevisionPlugin = require('git-revision-webpack-plugin')

module.exports = {
  'chainWebpack': config => {
    config.plugin('define').tap(args => {
      const gitRevisionPlugin = new GitRevisionPlugin()
      args[0]['process.env']['COMMIT_HASH'] = JSON.stringify(gitRevisionPlugin.commithash())
      return args