Livereload undoes replacements in my hook?

I am using an “after_prepare” hook similar to the Replace Text Depending on Environment hook discussed in this blog post:

Here is my hook:

Running or emulating the app without livereload, the strings are replaced and my app works as intended. When I livereload, the console shows logs from my hook, but the staged javascript files do not have the replacement. How can I make the hook function normally for livereload?

I am replacing URLs that will be proxied for livereload. If there is a better way than this hook, could you point me to it?

Hmm, I tested out a hook and it seems to work fine for me.
What are you editing with your hook?
Could you provide a sample project on github for me to checkout?

Ionic 1.2.5 / Cordova 4.0.0 / OSX 10.10.4 / node v0.10.33

I made a quick demo project and my hook is not working with or without livereload. Hopefully this can help illuminate my hooks understanding. Thanks!

My hook replaces a given tag with a specified URL in the generated javascript files in eg. platforms/ios/www/js. It seems like the hook is working but then the files are overwritten again in the case of livereload.

Did you have a chance to look at the sample project?