admin管理员组文章数量:1421046
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
本文标签: javascriptMeteorHow to Use a Package in Dev or Production OnlyStack Overflow
版权声明:本文标题:javascript - Meteor - How to Use a Package in Dev or Production Only - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745337462a2654106.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论