jbe*_*nab 36 deployment meteor
当流星应用程序作为开发,测试或生产环境运行时,我需要使用不同的帐户提供程序的配置.
Zia*_*rno 60
从Meteor 1.3开始,这些标志开箱即用:
Meteor.isDevelopment
Meteor.isProduction
Meteor.isTest
Meteor.isAppTest
Run Code Online (Sandbox Code Playgroud)
Nei*_*eil 32
在服务器上:
var inDevelopment = function () {
return process.env.NODE_ENV === "development";
};
var inProduction = function () {
return process.env.NODE_ENV === "production";
};
Run Code Online (Sandbox Code Playgroud)
运行时,Meteor将环境变量NODE_ENV设置为"development" meteor
.在生产中,您可以将变量设置为您想要的任何值,否则它将默认为"生产".
更新:我创建了一个智能包,允许它在客户端和服务器上工作.
mrt add allow-env
Run Code Online (Sandbox Code Playgroud)
只需在服务器文件中设置权限规则即可.
allowEnv({
NODE_ENV: 1
});
Run Code Online (Sandbox Code Playgroud)
go-*_*leg 18
您可以使用运行时Meteor.settings
使用的--settings
选项meteor run
或meteor deploy
.
例如,要以dev
模式运行,请创建一个JSON文件,将其命名为meteorConfigDev.json,并将以下内容放入其中:
{
"public" : {
"mode" : "dev"
},
"anotherProperty" : "anotherValue"
}
Run Code Online (Sandbox Code Playgroud)
使用运行您的应用
meteor --settings meteorConfigDev.json
Run Code Online (Sandbox Code Playgroud)
在服务器和客户端上,您可以使用以下命令访问"模式":
Meteor.settings.public.mode //in this case it will be "dev"
Run Code Online (Sandbox Code Playgroud)
请注意,"public"中的设置在服务器和客户端都可用,而其他所有设置(在本例中为"anotherProperty")仅在服务器上可用.
然后,您可以为不同的环境提供不同的配置文件.
归档时间: |
|
查看次数: |
10970 次 |
最近记录: |