简体   繁体   中英

Passing external configuration / parameters to a Meteor *mobile* build?

I need to be able to pass configuration values / parameters or similar to a Meteor mobile build - so that these values may be accessible to the Meteor code running on the device.

I was looking for something similar to how a settings file is passed to a Meteor server deploy (via meteor --settings settings.json ) but for a mobile build.

I thought meteor's mobile-config.js may have been a possibility but it's limited to certain inputs and doesn't appear to be available to the app after it's built.

Even the ability to package up a text-file during the build would be useful as it could then be read using something like https://github.com/apache/cordova-plugin-file .

Any ideas?

Thanks in advance.

Note that if you need to switch based on environment variables in your mobile-config.js file, like this:

if (this.process.env.NODE_ENV === 'production') {

  // production 

} else {

  // local
}

--mobile-settings

$ NODE_ENV=production 
$ meteor build ../app --server http://<app-server> --mobile-settings settings.json

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