var minify = require('html-minifier').minify
  , loaderUtils = require('loader-utils')

module.exports = function(source) {
  this.cacheable && this.cacheable()
  var defaultOptions = {
        removeComments: true,
        collapseWhitespace: true
      }
    , options = this.options && this.options['html-minifier-loader'] || {}
    , options2
  try {
    options2 = loaderUtils.getOptions(this)
  } catch(e) {
    options2 = {}
  }
  return minify(source, Object.assign(defaultOptions, options, options2))
}

var minify = require('html-minifier').minify
  , loaderUtils = require('loader-utils')

module.exports = function(source) {
  this.cacheable && this.cacheable()
  var defaultOptions = {
        removeComments: true,
        collapseWhitespace: true
      }
    , options = this.options['html-minifier-loader'] || {}
    , options2
  try {
    options2 = loaderUtils.getOptions(this)
  } catch(e) {
    options2 = {}
  }
  return minify(source, Object.assign(defaultOptions, options, options2))
}

--- 
+++ 
@@ -7,7 +7,7 @@
         removeComments: true,
         collapseWhitespace: true
       }
-    , options = this.options && this.options['html-minifier-loader'] || {}
+    , options = this.options['html-minifier-loader'] || {}
     , options2
   try {
     options2 = loaderUtils.getOptions(this)
Add support for webpack >= 4
