How to read Meteor settings from a build plugin

138 views Asked by At

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?

1

There are 1 answers

0
Mikkel On

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.