The METEOR_SETTINGS environment variable can accept JSON objects, and will expose that object in the Meteor.settings
object. First, add a settings.json
to your app root with some configuration info.
{
"public":{
"ga":{
"account":"UA-XXXXXXX-1"
}
}
}
Then you'll need to launch your application using your settings file.
# run your app in local development mode with a settings file
meteor --settings settings.json
# or bundle and prepare it as if you're running in production
# and specify a settings file
meteor bundle --directory /path/to/output
cd /path/to/output
MONGO_URL="mongodb://127.0.0.1:27017" PORT=3000 METEOR_SETTINGS=$(cat /path/to/settings.json) node main.js
These settings can then be accessed from Meteor.settings and used in your app.
Meteor.startup(function(){
if(Meteor.isClient){
console.log('Google Analytics Account', Meteor.settings.public.ga.account);
}
});