Build time / dynamic configurations per environment (mobile-config, etc.)

Luke,

We had the same problem when trying to specify our Facebook App test ID vs production ID. The problem is that I believe mobile-config.js is in regular node land and is read before Meteor even gets started. While definitely not ideal, I solved this with mobile-config.js code that looked like this:

if (this.process.env.NODE_ENV === 'production') {
  App.configurePlugin('com.phonegap.plugins.facebookconnect', {
    APP_ID: 'XXXXXX', // production FB app ID
    APP_NAME: 'My App'
  });
}
else {
  App.configurePlugin('com.phonegap.plugins.facebookconnect', {
    APP_ID: 'XXXXXX', // test FB app ID
    APP_NAME: 'My App Development'
  });
}

Then, I ran meteor like this:

$ NODE_ENV=production meteor build ../<app-name>-build --server http://<app-server> --mobile-settings settings.json

I put that long command in my package.json file and run it like this:

$ npm run build

[1] https://github.com/Differential/meteor-mobile-cookbook/blob/master/iOS/Building.md
[2] http://blog.differential.com/use-package-json-in-your-meteor-app-for-fun-profit/

HTH,
Gerard

6 Likes