old_contents: var runGitCommand = require('./helpers/run-git-command')
  
  module.exports = function buildFile (compiler, gitWorkTree, command, replacePattern, asset) {
    var data = ''
  
    compiler.plugin('compilation', function (compilation) {
      compilation.plugin('optimize-tree', function (chunks, modules, callback) {
        runGitCommand(gitWorkTree, command, function (err, res) {
          if (err) { return callback(err) }
          data = res
  
          callback()
        })
      })
  
      compilation.mainTemplate.plugin('asset-path', function (path) {
        return path.replace(replacePattern, data)
      })
    })
  
    compiler.plugin('emit', function (compilation, callback) {
      compilation.assets[asset] = {
        source: function () {
          return data
        },
        size: function () {
          return data.length
        }
      }
  
      callback()
    })
  }
  
new_contents: var runGitCommand = require('./helpers/run-git-command')
  
  module.exports = function buildFile (compiler, gitWorkTree, command, replacePattern, asset) {
    var data = ''
  
    compiler.hooks.compilation.tap('compilation', (compilation) => {
      compilation.hooks.optimizeTree.tapAsync('optimize-tree', (chunks, modules, callback) => {
        runGitCommand(gitWorkTree, command, function (err, res) {
          if (err) { return callback(err) }
          data = res
  
          callback()
        })
      })
  
      compilation.mainTemplate.hooks.assetPath.tap('asset-path', (path) => {
        return path.replace(replacePattern, data)
      })
    })
  
    compiler.hooks.emit.tapAsync('emit', (compilation, callback) => {
      compilation.assets[asset] = {
        source: function () {
          return data
        },
        size: function () {
          return data.length
        }
      }
  
      callback()
    })
  }
  
subject: Update build-file to Webpack 4 to use .hooks instead of .plugin