I am writing a hybrid app, there are several separate html/js would be loaded into different Android webviews.
For debugging, I have to change the base Url for my ajax request, due to the different network connection, different co-workers...
But the different urls are in many JS files.
//file1.js
baseUrl = "192.168.1.114:3000";
//file2.js
baseUrl = "192.168.1.114:3000";
//file3.js
// there are the same baseUrl;
I would like to configure and modify all of these fields at the same time for production or debugging. How? Having a Grunt? or Ajax a configuration file before ajax other url?
What is the best way to solve this problem?
There are many approaches and it's impossible to decide what is better because the best solution resides always in the middle...
For example, doing that via build-tools (grunt, gulp, ecc...), gives you the ability to work with different configurations trasparently, but, you lose the ability to switch ENV at runtime...
How I can test staging domains in production environments?
So, my experience says that the best solution is to create an hybrid system, for example:
Via grunt-contrib-uglify (for example), at the compilation time, you can pass all (or just importants) configurations available and, using another variable called ENV (var ENV = 'PRODUCTION')
you can let your application decide which of them use...
Hope it helps!