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'
4

2 回答 2

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.

于 2015-03-16T19:54:22.327 回答
1

我设法通过编写一个简单的含羞草插件来实现我想要的。有了它我可以写

/%= api %/

并将其替换为配置中的值。

于 2015-03-17T19:15:28.623 回答