Skip to content

Commit 29a8442

Browse files
committed
feat: compatible with html-webpack-plugin
1 parent c549c8c commit 29a8442

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,8 @@ HtmlRspackTagsPlugin.prototype.apply = function (compiler) {
581581
};
582582

583583
const HtmlWebpackPlugin = htmlPluginName === 'HtmlRspackPlugin' ? webpack.HtmlRspackPlugin : require(htmlPluginName);
584-
if (HtmlWebpackPlugin.getCompilationHooks) {
585-
const hooks = HtmlWebpackPlugin.getCompilationHooks(compilation);
584+
if (HtmlWebpackPlugin.getHooks || HtmlWebpackPlugin.getCompilationHooks) {
585+
const hooks = (HtmlWebpackPlugin.getHooks || HtmlWebpackPlugin.getCompilationHooks)(compilation);
586586
const htmlPlugins = compilation.options.plugins.filter(plugin => plugin instanceof HtmlWebpackPlugin);
587587
if (htmlPlugins.length === 0) {
588588
const message = "Error running html-webpack-tags-plugin, are you sure you have html-webpack-plugin before it in your webpack config's plugins?";

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@
4949
},
5050
"homepage": "https://github.com/rspack-contrib/html-rspack-tags-plugin",
5151
"peerDependencies": {
52-
"@rspack/core": "^1.0.13"
52+
"@rspack/core": "^1.0.13",
53+
"html-webpack-plugin": "^5.6.0"
54+
},
55+
"peerDependenciesMeta": {
56+
"html-webpack-plugin": {
57+
"optional": true
58+
}
5359
},
5460
"devDependencies": {
5561
"cheerio": "1.0.0-rc.10",

0 commit comments

Comments
 (0)