1

I have a typical mimosa front-end project with coffeescript for scripting. I want a certain variable (api path) to have different values, depending on build profile (dev or prod). How can I achieve this in mimosa?

Example of what I want:

prod.coffee:

exports.api = 'myserver'

dev.coffee:

exports.api = 'localhost'

api-accessor.coffee

config = getCurrentConfig(); # this is the part I do not know how to implement
exports.getStuff = () ->
  # here I want config.api to have different values depending on build profile
  $.ajax config.api + 'getStuff'
ironic
  • 8,368
  • 7
  • 35
  • 44

2 Answers2

1

You can put environment variables in your build profiles.

So instead of exports.api = "localhost", use process.env.api = "localhost".

Then when that profile is used, those variables are attached the env and accessible anywhere.

That's how we've solved this sort of thing.

David Bashford
  • 605
  • 4
  • 6
1

I managed to achieve what I want by writing a simple mimosa plugin. With it I can write

/%= api %/

and have it replaced with a value from config.

ironic
  • 8,368
  • 7
  • 35
  • 44