Can't prevent worker.js from being reset after modification

Because I’m deploying React with react-router, the url’s don’t work right out of the box if you’re doing a new request vs through it’s own hooks, so I modified my script so that it’d strictly load the only existing index.html file.

The new code I made to replace new Request(i.toString(),a) would be new Request(i.origin+"/index.html",a) and that’s how the worker site would work out perfectly, but when I use the commands wrangler build or wrangler publish, the code would revert back to the old version.

Has anyone gone through this type of issue, and were they ever able to prevent it from changing automatically?