gruntjs - Handling environment-specific configuration in a javascript app -


context : single-page backbone application build yeoman

i way have application parameters depend on current environment (dev vs production).

right using 2 separate config files, , switch dev 1 prod 1 when deploying grunt:usemin task :

// index.html <!-- build:js scripts/config.prod.js --> <script src="scripts/config.dev.js"></script> <!-- endbuild -->      // config.dev.js window.config = {     api_host: 'localhost:9393',     api_key:  'dev_api_key' }  // config.prod.js window.config = {     api_host = 'api.host.tld',     api_key =  'prod_api_key' } 

this solution works smelly , doesn't allow other environment production , dev. alternatives?

try this:

var dev = (window.location.indexof("dev=1")) != -1 ? true : false; 

then type ?dev=1 after url.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -