Skip to content

Commit

Permalink
improve: Changed tap type of html-webpack-plugin hook
Browse files Browse the repository at this point in the history
Signed-off-by: Jaid <jaid.jsx@gmail.com>
  • Loading branch information
Jaid committed Jun 19, 2021
1 parent d31b77b commit 4f4d950
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,15 @@ export default class InjectBodyPlugin {
debug("Options: %o", this.options)
compiler.hooks.compilation.tap(process.env.REPLACE_PKG_NAME, compilation => {
debug("tap: compilation")
HtmlWebpackPlugin.getHooks(compilation).beforeEmit.tapAsync(process.env.REPLACE_PKG_NAME, (data, callback) => {
debug("tapAsync: html-webpack-plugin beforeEmit")
HtmlWebpackPlugin.getHooks(compilation).beforeEmit.tap(process.env.REPLACE_PKG_NAME, data => {
debug("tap: html-webpack-plugin beforeEmit")
debug("Before: %s", data.html)
if (this.options.position === "end") {
data.html = insertStringBefore(data.html, "</body>", this.options.content)
} else {
data.html = insertStringAfter(data.html, "<body>", this.options.content)
}
debug("After: %s", data.html)
callback(null, data)
})
})
}
Expand Down

0 comments on commit 4f4d950

Please sign in to comment.