In Meteor, is there a way to specify a package to be used in the development environment only, or the production environment only? When I add packages via astmospherejs.com, they all get lumped into the .meteor/packages
file sorted chronologically by time added. Essentially, I'm looking for what would be a ruby Gemfile, where you can specify different environments. Thanks!
To use an Atmosphere Package in your app you can import it with the meteor/ prefix: import { Mongo } from "meteor/mongo"; Typically a package will export one or more symbols, which you'll need to reference with the destructuring syntax. You can find these exported symbols by either looking in that package's package.
Meteor is a full-stack JavaScript platform for developing modern web and mobile applications. Meteor includes a key set of technologies for building connected-client reactive applications, a build tool, and a curated set of packages from the Node. js and general JavaScript community.
Here's a little trick I've been using to run a package in development only:
from your app root, create a blank package (or add to your PACKAGE_DIRS
directory): meteor create --package my-package-manager
In package.js:
Package.on_use(function(api) {
// production only
if (process.env.IS_PRODUCTION) {
api.use('some:package');
}
// dev only
if (process.env.IS_DEVELOPMENT) {
api.use('devonly:package');
}
});
On dev environment: echo "export IS_DEVELOPMENT=true" >> ~/.bash_profile
(or ~/.zshrc
in my case)
Then obviously do the same thing for IS_PRODUCTION
on whatever you use for production server. on heroku for example: heroku config:set IS_PRODUCTION=true
I'm using this for a dev-only package, haven't tried it with production-only but it should work.
From meteor version 1.3.2, you can simply put the flag prodOnly
or debugOnly
.
More info here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With