简体   繁体   中英

How to read Meteor settings from a build plugin

I'm currently working on a package for Meteor that includes a build plugin. I need to access configurations from the settings file.

However Meteor.settings doesn't work ( Meteor is not defined ) and process.env.METEOR_SETTINGS also doesn't exist.

Is there any way for my plugin to access the settings file?

It appears that despite the documentation discussing the use of --settings, it doesn't work in a production environment, as often command line options are not available.

So the solution is to use environment variables, which are available only on the server.

server code, meteor methods:

eor methods
Meteor.methods({
    getPJS: function() {
        return process.env.PEERJS_SERVER;
    },

client code

var PJS = Meteor.call("getPJS");

So you can make those environment variables available on the client if you need them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM