高階環境配置
對於更復雜的應用程式,你需要使用多個環境變數構建``settings.json`物件。
if(Meteor.isServer){
Meteor.startup(function()){
// this needs to be run on the server
var environment, settings;
environment = process.env.METEOR_ENV || "development";
settings = {
development: {
public: {
package: {
name: "jquery-datatables",
description: "Sort, page, and filter millions of records. Reactively.",
owner: "LumaPictures",
repo: "meteor-jquery-datatables"
}
},
private: {}
},
staging: {
public: {},
private: {}
},
production: {
public: {},
private: {}
}
};
if (!process.env.METEOR_SETTINGS) {
console.log("No METEOR_SETTINGS passed in, using locally defined settings.");
if (environment === "production") {
Meteor.settings = settings.production;
} else if (environment === "staging") {
Meteor.settings = settings.staging;
} else {
Meteor.settings = settings.development;
}
console.log("Using [ " + environment + " ] Meteor.settings");
}
});
}