setting core-ajax development/production url with grunt

I am trying to build a Polymer webapp that relies on REST APIs based on a Node.js backend. I have scaffolded my project with Yeoman and using Mongoskin to create a RESTful interface with the backend.

I am using the core-ajax element passing it my localhost url when I am developing, however every time I deploy to heroku I have to change this url to connect to the right backend APIs.

I believe I can access the process.env.NODE_ENV variable only backend side, therefore I am asking if there is a way to tell grunt to change this url when I build my dist folder.

The only option I have in mind is:

  • Create a globals-element with the url
  • Setting the production url in this element in the index.html
  • Setting the localhost url in this element in a new development.html that I will use while testing locally
  • Exclude development.html the during the grunt build

Is there a more elegant way to do that?