How to inject scripts to index html file in production?

Author: NetanelBasalCreated Dec 9, 2015Updated Sep 14, 2021

I have a index html file and i need to inject in production ENV additional scripts. with gulp i can do this with plugin like gulp inject, How can i do this with webpack?

For example:

xml
<script src="script.js"></script>
// I want this script only in the production index html file
<script src="script2.js"></script>