jantimon / html-webpack-plugin

Simplifies creation of HTML files to serve your webpack bundles
MIT License
10.71k stars 1.31k forks source link

How to add `onerror` event to the generated script tag? #1851

Closed anchor-sherry closed 5 months ago

anchor-sherry commented 5 months ago

This is a very powerful plugin!

But I'm so sad that I have a problem.

How can I insert onerror property to my target script tag which is generated by this plugin?

Just like this:

<script defer="defer" src="assets/js/vender.c3803732.bundle.js" **onerror="handleError()"**></script>
alexander-akait commented 5 months ago

You can create a custom plugin if you need it, look at our docs how to change HTML content - https://github.com/jantimon/html-webpack-plugin?tab=readme-ov-file#beforeemit-hook

feel free to feedback