Say like we have in Spring Framework a lot of variations to set compile/run/test time environment, and use it to bind a different properties files with settings. It is made for us not to change anything except this one environment/profile variable to be able to have proper settings for app.
More particularly:
I have two files: settings.dev.js and settings.prod.js
settings.prod.js:
var API_PATH = "http://example.com/api"
var OTHER_INPORTANT_SETTINGS = {....}
settings.dev.js:
var API_PATH = "http://localhost.com/api"
var OTHER_INPORTANT_SETTINGS = {....}
and an Ionic Framework app where services are using this settings. E.g.
me: $resource(API_PATH + '/my/profile', {}, {...}
And so on in many services and controllers and maybe directives...
Is there some way to use
I just develop a solution for the issue.
Create a grunt task (or the equivalent build tools) to copy the settings.<env>.js
file to settings.js
file.
copy: {
dev: {
src: 'settings.dev.js',
dest: 'settings.js'
},
prod: {
src: 'settings.prod.js',
dest: 'settings.js'
}
},
grunt.registerTask('dev', [
'copy:development'
]);
grunt.registerTask('prod', [
'copy:prod'
]);
Include settings.js
in your html or js file.
Add settings.js
to your .gitignore
file so that your environment specific file won't affect others.