Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit 4094cd9

Browse files
committed
fix #185 (by @HASSANDL)
1 parent 046946b commit 4094cd9

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,12 @@ module.exports = class WebappWebpackPlugin {
7171
this.tags.resolve(tags);
7272

7373
// Hook into the html-webpack-plugin processing and add the html
74-
try {
75-
const HtmlWebpackPlugin = require('html-webpack-plugin');
76-
await HtmlWebpackPlugin.getHooks(compilation).alterAssetTags.tapPromise('WebappWebpackPlugin', async htmlPluginData => {
74+
const htmlWebpackPlugin = compiler.options.plugins
75+
.map(({ constructor }) => constructor)
76+
.find(({ name }) => name === 'HtmlWebpackPlugin');
77+
78+
if (htmlWebpackPlugin) {
79+
await htmlWebpackPlugin.getHooks(compilation).alterAssetTags.tapPromise('WebappWebpackPlugin', async htmlPluginData => {
7780
if (this.options.inject(htmlPluginData.plugin)) {
7881
htmlPluginData.plugin.options.inject = true;
7982
[].push.apply(
@@ -87,8 +90,6 @@ module.exports = class WebappWebpackPlugin {
8790
}
8891
return htmlPluginData;
8992
});
90-
} catch (_) {
91-
// html-webpack-plugin is not available, skip html tag injection.
9293
}
9394
} catch (err) {
9495
this.tags.reject(err);

0 commit comments

Comments
 (0)