Working with javascript environments using Grunt

Asked

Viewed 125 times

2

I have a very bad problem in my web projects, I don’t work with environments, I wanted my application to have different configuration types according to the environment, for example: in the DEV environment my application accesses one server and in the PROD environment it accesses another. For that I would have to have a Grunt task that changes variables in my script when deploying, someone knows how to do this ?

This is my Gruntfile

  • Utilise environment variables does not solve your problem? You can access them using process.env.VARIAVEL.

  • No, it’s my script settings that will run in the browser.

  • Ah, of course. Well, anyway, there’s no way to pass the settings to two files .js separated (config-dev.js and config-prod.js, for example) and define when to use each in the Gruntfile.js?

  • Could post your Gruntfile.js?

  • @gabrielhof put the link in my question

  • One last question, do you want to access these servers via AJAX? If so, you intend to use JSONP for this?

  • It will be an HTML5 application consuming a PHP Webservice. And I don’t use JSONP only JSON

Show 3 more comments

1 answer

1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.