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, 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!
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., 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!
-
3
Well, in the
Package.describe
callback (package.js
file) you can setdebugOnly: true
in order to not deploy the package when usingmeteor deploy
, for example to use a collection populating code you don't want to use in prod. Hope it will help! – Kyll Commented Mar 22, 2015 at 10:45 - Useful. Unfortunately, this is not yet documented. I'm looking for a "productionOnly" but that doesn't seem to exist. – foobarbecue Commented Apr 16, 2015 at 15:04
2 Answers
Reset to default 7Here'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