Skip to content

Commit 4b2088c

Browse files
author
Anuj Nair
committed
Removing support for webpack 2 and 3, and html-webpack-plugin 3
1 parent ba767f3 commit 4b2088c

File tree

1 file changed

+10
-44
lines changed

1 file changed

+10
-44
lines changed

plugin.js

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -349,50 +349,16 @@ class CspHtmlWebpackPlugin {
349349
* @param compiler
350350
*/
351351
apply(compiler) {
352-
if (compiler.hooks) {
353-
compiler.hooks.compilation.tap('CspHtmlWebpackPlugin', (compilation) => {
354-
if (HtmlWebpackPlugin && HtmlWebpackPlugin.getHooks) {
355-
// HTMLWebpackPlugin@4
356-
/* istanbul ignore next */
357-
HtmlWebpackPlugin.getHooks(
358-
compilation
359-
).beforeAssetTagGeneration.tapAsync(
360-
'CspHtmlWebpackPlugin',
361-
this.mergeOptions.bind(this, compilation)
362-
);
363-
/* istanbul ignore next */
364-
HtmlWebpackPlugin.getHooks(compilation).beforeEmit.tapAsync(
365-
'CspHtmlWebpackPlugin',
366-
this.processCsp.bind(this)
367-
);
368-
} else if (
369-
compilation.hooks.htmlWebpackPluginBeforeHtmlGeneration &&
370-
compilation.hooks.htmlWebpackPluginAfterHtmlProcessing
371-
) {
372-
// HTMLWebpackPlugin@3
373-
compilation.hooks.htmlWebpackPluginBeforeHtmlGeneration.tapAsync(
374-
'CspHtmlWebpackPlugin',
375-
this.mergeOptions.bind(this, compilation)
376-
);
377-
compilation.hooks.htmlWebpackPluginAfterHtmlProcessing.tapAsync(
378-
'CspHtmlWebpackPlugin',
379-
this.processCsp.bind(this)
380-
);
381-
}
382-
});
383-
} else {
384-
/* istanbul ignore next */
385-
compiler.plugin('compilation', (compilation) => {
386-
compilation.plugin(
387-
'html-webpack-plugin-before-html-generation',
388-
this.mergeOptions.bind(this, compilation)
389-
);
390-
compilation.plugin(
391-
'html-webpack-plugin-after-html-processing',
392-
this.processCsp.bind(this)
393-
);
394-
});
395-
}
352+
compiler.hooks.compilation.tap('CspHtmlWebpackPlugin', (compilation) => {
353+
HtmlWebpackPlugin.getHooks(compilation).beforeAssetTagGeneration.tapAsync(
354+
'CspHtmlWebpackPlugin',
355+
this.mergeOptions.bind(this, compilation)
356+
);
357+
HtmlWebpackPlugin.getHooks(compilation).beforeEmit.tapAsync(
358+
'CspHtmlWebpackPlugin',
359+
this.processCsp.bind(this)
360+
);
361+
});
396362
}
397363
}
398364

0 commit comments

Comments
 (0)