javascript - Is there a way to use different environment profiles for development and production setting for Cordova app based on Ionic Framework -
say have in spring framework lot of variations set compile/run/test time environment, , utilize bind different properties files settings. made not alter except 1 environment/profile variable able have proper settings app.
more particularly:
i have 2 files: settings.dev.js , 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 ionic framework app services using settings. e.g.
me: $resource(api_path + '/my/profile', {}, {...} and on in many services , controllers , maybe directives...
is there way utilize
settings.dev.js while in development , settings.prod.js deployment release app.
as 1 of approaches can utilize grunt.
grunt.registertask('dev', ['processhtml:dev']); grunt.registertask('default', ['processhtml:prod', ...]); in html:
<!-- build:remove:dev --> <script src="/your/path/settings.prod.js"></script> <!-- /build --> <!-- build:remove:prod --> <script src="/your/path/settings.dev.js"></script> <!-- /build --> it means <script src="/your/path/settings.prod.js"></script> removed dev, , <script src="/your/path/settings.dev.js"></script> removed prod.
now build production environment utilize grunt command, , build development env. utilize grunt dev.
and 1 more thing, can utilize grunt-contrib-watch automate dev builds:
watch: { html: { files: ['www/*.html'], tasks: ['dev'] } } hope help someone.
javascript cordova gruntjs ionic-framework hybrid-mobile-app
No comments:
Post a Comment