From 8571048b5e71eb782696ec5442aadb7942067c4d Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Fri, 15 May 2020 20:45:18 +0200 Subject: [PATCH] [TASK] Webpack 4 compatiblity --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ac0b5b6..ae41103 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,8 @@ var mkdirp = require('mkdirp'); var path = require('path'); var RawSource = require("webpack-sources/lib/RawSource"); +const HtmlWebpackPlugin = require('html-webpack-plugin'); + function HtmlWebpackAlterDataPlugin (options) { this.options = { assetsConstants: false, @@ -44,7 +46,9 @@ HtmlWebpackAlterDataPlugin.prototype.apply = function (compiler) { }); compiler.hooks.compilation.tap('HtmlWebpackAlterDataPlugin', (compilation) => { - compilation.hooks.htmlWebpackPluginAfterHtmlProcessing.tapAsync('HtmlWebpackAlterDataPlugin', (data, cb) => { + const beforeEmit = compilation.hooks.htmlWebpackPluginAfterHtmlProcessing || + HtmlWebpackPlugin.getHooks(compilation).beforeEmit; + beforeEmit.tapAsync('HtmlWebpackAlterDataPlugin', (data, cb) => { data.html = data.html.replace('', ''); data.html = data.html.replace(//g, '');