Skip to content

Commit 9d4cacb

Browse files
authored
fix: Simplify mini-css-extract-plugin fix (#44)
It looks like there's a specific API in webpack 5 to guarantee emitting only once.
1 parent 054add6 commit 9d4cacb

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/index.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,12 @@ class MiniHtmlWebpackPlugin implements WebpackPluginInstance {
221221

222222
public apply(compiler: webpack.Compiler) {
223223
const pluginName = 'MiniHtmlWebpackPlugin';
224-
let registeredAlready = false;
225224

226225
if (isWebpack4()) {
227226
// @ts-ignore: Ignore for webpack 4 due to different typing
228227
compiler.hooks.emit.tapAsync(pluginName, this.webpack4plugin);
229228
} else {
230-
compiler.hooks.compilation.tap(pluginName, (compilation) => {
231-
if (registeredAlready) {
232-
return;
233-
}
234-
229+
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
235230
compilation.hooks.processAssets.tapPromise(
236231
{
237232
name: pluginName,
@@ -240,8 +235,6 @@ class MiniHtmlWebpackPlugin implements WebpackPluginInstance {
240235
},
241236
() => this.webpack5plugin(compilation)
242237
);
243-
244-
registeredAlready = true;
245238
});
246239
}
247240
}

0 commit comments

Comments
 (0)